A127 === Subject: N00b help needed: Graphics I have a very simple problem: Visualization of two data sets f={{x1,y1},{x2,y2},...} and g={{X1,Y1},{X2,Y2},...}. The first set shall be replaced by an interpolated curve: F=Interpolation[f]. OK, that was trivial :-) The second shall be shown as small dots overlayed on the graph of f. Where is the problem, you ask? The problem is my uni has version 5 and all the Graphics primitives as shown on the Wolfram Internet site give no visible output or even error messages! Surely you have a command Plot[something_with_f_and_g] for me working for any data lists? (Spline madness is no issue, F is very smooth with my actual test data set f.) THX, -- Hauke Reddmann <:-EX8 fc3a501@uni-hamburg.de Nur Schufte schuften - Genie genie§t. === Subject: Re: Maximization problems Binomial is not an integer function Binomial[3.2, 1.6] 3.79518 Binomial[1.6, 3.2] -0.0498545 It is not even restricted to Reals Binomial[m, n] // FunctionExpand Gamma[m + 1]/(Gamma[n + 1]*Gamma[m - n + 1]) Binomial[2. + 3 I, 1 - 2 I] 91.9097-72.4149 I Bob Hanlon from your input, Mathematica assunmes a domain of Reals. But then it can not \ evaluate the integer function Binomial. If you specify an Integer domain, Mathematica will duly return (after a long time): {60, {b -> 10, m -> 10, s -> 10, a -> 10, n -> 10, r -> 10}} hope this helps, Daniel > > consider a toy function 'func' of 6 parameters, and a set of > constraints 'cons' for this function: > > In[45]:= func[b_, m_, s_, a_, n_, r_] := Total[{b, m, s, a, n, r}]; > cons[b_, m_, s_, a_, n_, r_] := > And[3 <= a <= 10, 1 <= n <= 10, 1 <= r <= n, 3 <= b <= 10, > 1 <= m <= b, 1 <= s <= m, Binomial[b, m] <= a^n]; > > In[47]:= NMaximize[{func[b, m, s, a, n, r], > And[cons[b, m, s, a, n, r]] > }, {b, m, s, a, n, r}] > > Out[47]= {60., {b -> 10., m -> 10., s -> 10., a -> 10., n -> 10., > r -> 10.}} > > In[48]:= Maximize[{func[b, m, s, a, n, r], > And[cons[b, m, s, a, n, r]] > }, {b, m, s, a, n, r}] > > Out[48]= Maximize[{a + b + m + n + r + s, > 3 <= a <= 10 && 1 <= n <= 10 && 1 <= r <= n && 3 <= b <= 10 && > 1 <= m <= b && 1 <= s <= m && Binomial[b, m] <= a^n}, {b, m, s, a, > n, r}] > > While NMaximize gives the correct answer, Maximize is returned > unevaluated. If I remove the last constraint from cons, then Maximize > succeeds as well. Now why is it, that the symbolic method can't > maximize the function? Any idea? > > Istvan Zachar === Subject: Re: voices for version 7 text-to-speech I persisted in trying to get clarification from NaturalSoft. The confusion seemed to be that a \voice\ in itself cannot work with a 3rd-party program. But they actually supply is a \voice + voice engine\, and that does work with any program that addresses the Windows Text-to-Speech API. So I did buy the NaturalSoft NaturalReader Pro package, which includes two of their voices/engines and two of the NeoSpeech voices/engines, along with a text-to-speech application and text-to-MP3 converter. The voices/engines work just fine with Mathematica's Speak -- MUCH less choppy and more natural sounding than the rather awful voices that Microsoft supplies. > Mathematica 7 has the function Speak, and related functions, that read > the argument aloud, using the OS's text-to-speech (TTS) capability. > > I'm using this with Windows XP. What happens, evidently, is that > Mathematica calls the Windows SAPI (SAPI4? SAPI5?) interface. And that > interface in turn calls the built-in Windows TTS engine/voice. > > The Microsoft-supplied voice is very unnatural. I want to replace it. > But I'm confused as to whether the 3rd-party TTS products such as > NaturalReader and Neospeech VoiceText will in fact accomplish what I \ want. > > I think my confusion stems from the fact that a TTS voice also involves > a specific voice \engine\. > > I have been trying to get a straight answer from NaturalReader tech > support as to whether, if I installed their product, it would work with > Mathematica's Speak or not. But their English is not too good. The > first time I asked, they responded, \Natural voices always work in > NaturalReader. NaturalReader can read any text correctly including > mathematical expressions.\ When I asked for clarification, they > responded, \Natural voice only works with NaturalReader.\ > > I can't figure out whether this simply means that the engine behind the > NaturalReader TTS application is required to use the voices they supply > -- which would be what I want, I presume -- or whether, instead, that > the only way to use the voice is to go directly through text in the > NaturalReader application. > > Any information would be appreciated. -- 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: Expecting an image instead of image... I swear that I wasnt working in the doc center! (bad habit, I think...) yet by replicating everything in a new notebook worked OK, so I had to make some mistake... didnt know about the different environments though - good to know! alessandro On 24 Feb, 11:44, \Sjoerd C. de Vries\ > This is probably because you were working in the documentation centre. > It seems that the doc text contains separate environments (indicated > by dotted lines) which don't share variable values. The variable a > that you assigned is in one part and the MorphologicalComponents[a] > part in the other. If I try it like this I get a similar error > message. > > > On Feb 20, 12:45 pm, \alexxx.ma...@gmail.com\ > > > how I love these error messages, so clear... > > > I know it's more wysiwyg to copy&paste image icons on command lines, > > but I'm more used to do it the old way, also to remember where the > > image comes from... > > but I'm getting this funny message: > > > a = Import[\k0004b.tif\] > > <> > > > MorphologicalComponents[a] > > MorphologicalComponents::imginv: > > Expecting an image or graphics instead of Image[{{91,85... > > > do you know what's happening here? > > > alessandro === Subject: Map and functional constructs to replace iterative statements I have begun to replace Table, Do, While, or For, but in my thinking with \ Map, Inner, Outer and other functional programming constructs as I learn more \ about Mathematica. But, I'm stuck. I need to figure out how to use Map (or some related \ approach) when a function needs both a current value and a previous value in \ a time series, such as a percentage change function (or perhaps more \ generally stated, when I need to refer to previous values in a series or even \ previous calculations). But first a simple case: percentChange[currentValue_, previousValue_] := 100 * ( currentValue - \ previousValue) / previousValue I know how to apply this iteratively, but how can I do it with Map or some \ other functional construct? Say I have a list: timeSeries I thought to try something like this: Map[percentChange[?,?], timeSeries] but I don't know how what to put in for \?\. Any help much appreciated. Thx. === Subject: Re: question related to (-1)^(1/3) You COULD use the legacy RealOnly package: < I just want to get the real solution of (-1)^(1/3). > BTW, I have read the tutorial but I am still confused with its \ explanation. > But that is not important, I just feel it is inconvenient for the \ following > problem: > > RecurrenceTable[{x[n + 1] == -x[n]^(1/3), x[0] == 1}, x, {n, 1, 200}] // \ N > > I consider there should be a way to limit the output in the domain real. > for example, in MAXIMA > > (%i1) domain; > (%o1) real > (%i2) (-1)^(1/3); > (%o2) -1 > (%i3) domain:complex; > (%o3) complex > (%i4) (-1)^(1/3),numer; > (%o4) 0.86602540378444*%i+0.5 > > >> This misunderstanding pops up over and over again in this group. >> Please type tutorial/FunctionsThatDoNotHaveUniqueValues in the search >> bar of the mathematica doc centre. >> >> >> On Feb 22, 7:33 am, \=D2=BB=D2=B6=D6=AA=C7=EF\ \ = >>> I have tried expression: >>> RecurrenceTable[{x[n + 1] == -x[n]^(1/3), x[0] == 1}, >>> x, {n, 1, 200}] // N >>> >>> Mathematica produce >>> {-1., -0.5 - 0.866025 I, -0.766044 + 0.642788 I, -0.686242 - >>> 0.727374 I, -0.71393 + 0.700217 I, -0.704818 - 0.709389 I, >>> ... >>> >>> But it should be {1, -1, 1, -1, ... } >>> >>> If you try (-1)^(1/3) >>> >>> In[10]:= (-1)^(1/3) >>> >>> Out[10]= (-1)^(1/3) >>> >>> In[11]:= % // N >>> >>> Out[11]= 0.5 + 0.866025 I >> >> > -- 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: Series of Percentage Changes Hello everyone, We can transform a series to percentage changes by using (Differences@theList)/(Most@theList) or (Rest@theList/Most@theList) - 1 However, Mathematica will smartly difference symbols as well as numeric values, so the difference of adjacent null elements will be zero (Null - Null = 0), resulting in a percentage change of zero, and so will adjacent elements with a string, such as \NA\ or \Missing\, that denotes a missing value. The trouble is, you may want to have missing values flagged in the resulting percentage change series just as they were in the original series. to take care of missing values and instances of division by zero, but I was wondering whether there is a more elegant way to incorporate the conditions with functions such as Rest and Most and perhaps avoid the use of the loop. percentageChange[theList_] := Module[{tmpList, tmpElements}, (tmpList = Array[tmpElements, (Length@theList) - 1]; Do[tmpList[[t - 1]] = If[theList[[t - 1]] != 0 && NumberQ[theList[[t - 1]]] && NumberQ[theList[[t]]], theList[[t]]/theList[[t - 1]] - 1, \NA\], {t, 2, Length@theList}]; tmpList)]; Gregory === Subject: Re: Coolest Mathematica trick you'll see this month I'd write it this way: Clear[doubleBallMap, c2r4, spinKet] doubleBallMap[v : {w_, x_, y_, z_}] := {y, z, Sign[x]*(w + 1)/2}/ Sqrt[v.v]; c2r4[{w_, x_}] := {Re[w], Im[w], Re[x], Im[x]}; spinKet[\\[Beta]_, t_] := {Sin[\\[Beta]/2] Exp[-I 2 \\[Pi] t], Cos[\\[Beta]/2] Exp[I 2 \\[Pi] t]}; ParametricPlot3D[ Map[(doubleBallMap[c2r4[spinKet[#, t]]]) &, Range[0, \\[Pi], \\[Pi]/16]], {t, 0, 2 \\[Pi]}] (All those Extract-ions are obtuse and distracting.) Drawing the 3D graphic initially is slow, but I don't get any problems when rotating the image. (That's what the post complained about.) I doubt most of us have \accelerometer\ drivers, so I can't help you with \ that, either. Bobby > I use Linux on my machines and enjoy helping other Archlinux users in > the online forums. A fellow Arch user was having issues with > Mathematica 7. He was plotting a 3D parametric equation and > experiencing a sustained high processor load on this laptop; only > killing the kernel would allow the CPU to idle down. He found that the > laptop's accelerometer kernel driver was eating nearly 30% of the CPU > time.... You'll just have to read the forum to see the rest! > > http://bbs.archlinux.org/viewtopic.php?id=65916 > > Can any Windows or Mac users duplicate this? Or is this a Linux-only > \feature\? Or maybe this is well-known and I'm just late in finding \ out? > > cjpembo > -- DrMajorBob@longhorns.com === Subject: MathLink message handler not set by default I struggled for a while to make my MathLink program (compiled for MS Windows in VC++ Express 2008) abortable following the procedure laid out in the MathLink tutorial to no avail; the global MLAbort variable which is supposed to become 1 when an abort message is sent by the kernel was never changed from zero despite regular calls to the yield function. While checking if kernel messages were getting through, in one of my routines I did printf(\Message Handler address: %p\\n\,MLMessageHandler(stdlink)); which printed zero indicating there was no valid message handler. The entry point of my program was the usual: int main(int argc, char *argv[]) { return MLMain(argc, argv); } After rummaging around the mprep-generated C file, I noticed the point where the yield function should be set: if( MLInstance){ if( stdyielder) MLSetYieldFunction( mlp, stdyielder); if( stdhandler) MLSetMessageHandler( mlp, stdhandler); } The problem is that MLInstance=0 always. I don't know what this variable is, it looks like a pointer that is set in some windows- related procedure called MLInitializeIcon(). As a work-around, before the return statement in main() I inserted: if(!MLInstance) MLInstance=(HANDLE)1; which forced the message handler to be set and now my program receives messages from the kernel as it should and aborts properly. Does anyone know why the message handler isn't set by itself or what MLInstance is? === Subject: Counting Categories Hello Everyone, I'm trying to do multivariate category counts in the way that used to be handled by CategoryCounts but is now replaced by Cases. The example in Help simply applies Cases twice to find the count of elements in a list that are numbers and the count that is even. Map[Cases[{a, b, c, 1, 2, d, 3}, #] &, {_?NumberQ, _?EvenQ}] {{1, 2, 3}, {2}} But what if I have many rows of observations on two dimensions (columns) such as red, blue, green, and small, medium, big? I'd like to be able categorize them accordingly as the count of small and red, medium and red, big and red, and so on. Any way to do that? Gregory === Subject: Re: no message from Minimize[] on a weird function(x^x) !?! I knew that this function is ill-behaved when x < 0. I have some other functions which are not so \simple\ as x^x. I use Minimize[] first rather than the numerical invocations since it knows how to handle an equation with parameters. I guess I want it to issue some message when it can't perform what I ask. I will start reading the \Possible Issues\ when I run into problems. > Beyond what others have already commented, I would say that the > problem stems with the definition of 0^0 which, in Mathematica, is > Indeterminate. In fact, even if the value of the function is > constrained to be real positive, Minimize behavior is influenced by > the value at 0: > > Minimize[{Abs[x^x], x > 0}, x] // InputForm > {E^(-E^(-1)), {x -> E^(-1)}} > > Minimize[{Abs[x^x], x < 0}, x] // InputForm > {0, {x -> -Infinity}} > > Minimize[{Abs[x^x], x >= 0}, x] // InputForm > Minimize[{Abs[x^x], x >= 0}, x] > > In fact, > > 0^0 > Indeterminate > > but > Limit[Abs[x^x], x -> 0] > 1. > > In conclusion, Minimize does not appear to compute limits and cannot > deal with \holes\ in the function's domain. > > ADL > > === Subject: Re: no message from Minimize[] on a weird function(x^x) > Beyond what others have already commented, I would say that the > problem stems with the definition of 0^0 which, in Mathematica, is > Indeterminate. I do not think the tests below show that to be the issue. > In fact, even if the value of the function is > constrained to be real positive, Minimize behavior is influenced by > the value at 0: > > Minimize[{Abs[x^x], x > 0}, x] // InputForm > {E^(-E^(-1)), {x -> E^(-1)}} 1/E<1, so there is no reason to expect that min to be at the origin. > Minimize[{Abs[x^x], x < 0}, x] // InputForm > {0, {x -> -Infinity}} 0<1, so... > Minimize[{Abs[x^x], x >= 0}, x] // InputForm > Minimize[{Abs[x^x], x >= 0}, x] These simply show that Minimize, at heart an exact algebraic function, does not know how to handle the input. > In fact, > > 0^0 > Indeterminate > > but > Limit[Abs[x^x], x -> 0] > 1. > > In conclusion, Minimize does not appear to compute limits and cannot > deal with \holes\ in the function's domain. > > ADL Nothing to do with 0^0 or holes in the domain. Try a variation of this function but with extremum, in a limiting sense, at 0, In[10]:= Maximize[{x^x, 0 < x <= 1/2}, x] During evaluation of In[10]:= Maximize::wksol: Warning: There is no maximum in the region in which the objective function is defined and the constraints are satisfied; returning a result on the boundary. >> Out[10]= {1, {x -> 0}} When x<0 the function is not in general real valued, hence problems arise there. NMinimize, howeverm can do sensible things with variants. Here are two such. In[16]:= NMinimize[{Re[x^x] + Im[x^x], -1 <= x <= 0}, x, Method -> \DifferentialEvolution\] Out[16]= {-1.79458, {x -> -0.687465}} In[17]:= NMinimize[{Re[x^x] - Im[x^x], -1 <= x <= 0}, x, Method -> \DifferentialEvolution\] Out[17]= {-1., {x -> -1.}} Daniel Lichtblau Wolfram Research === Subject: Re: Manipulating list of functions Hi all, we recently had a thread regarding manipulating a list of functions which worked fine:- Manipulate[Block[{funcA, funcB, funcC, funcList}, funcA[z_] := Sin[z + a]; funcB[z_] := Cos[z + b]; funcC[z_] := funcA[z] + funcB[z]; funcList = #[x] & /@ {funcA, funcB, funcC}; Plot[Evaluate[funcList], {x, 1, 10}, Axes -> False, Frame -> True]], {a, 0, Pi}, {b, 0, Pi}] I have tried what I thought would be a trivial a variant of this for very simple functions: Manipulate[ Block[{initialinvestment, nbrshares, profit, totalofholding, funcList}, initialinvestment := 100000; nbrshares[buyprice_] := initialinvestment/buyprice; profit[buyprice_] := (finalprice - buyprice)*nbrshares; totalofholding := profit + initialinvestment; funcList := #[x] & /@ {nbrshares, initialinvestment, profit, totalofholding}; Plot[Evaluate[funcList], {x, 4, 7}, Axes -> False, Frame -> True, PlotRange -> {0, 650000}]], {finalprice, 16, 24, 1}] However I only get the nbrshares plotted, after several attempts I cannot get the desired output and would appreciate advice as to why the simpler function specifications lead to failure. It appears that unless the functions all contain explicit references such as to \z\ in the first working example then they are omitted. Syd Geraghty B.Sc, M.Sc. sydgeraghty@mac.com Mathematica 7.0.0 for Mac OS X x86 (64 - bit) (21st November, 2008) MacOS X V 10.5.6 === Subject: Re: Interval arithmetic and Dependency problems Nice to see this discussion here. I was just trying out the Interval functions for a project where I need to compare two time intervals, and noticed what is, to me, unexpected behavior. Mathematica symbolizes a disjoint interval as Interval[], and this might result from, say IntervalIntersection[Interval[{0,1}], Interval[{2,4}]]. While I would like to think of this as a \null\ interval, one without any range (in particular Interval[{0,0}]), Mathematica instead treats this object as the same thing as Interval[{Infinity, -Infinity}], i.e. completely off the real line (not explained in the documentation). Therefore, Interval[{0,1}] + Interval[] == Interval[] (rather than Interval[{0,1}]) More importantly, I want to test if two intervals overlap or not. If they don't, IntervalIntersection[Interval[{0,1}], Interval[{2,4}]] == \ Interval[] returns True, which is fine, but if they *do* overlap, IntervalIntersection[Interval[{0,3}], Interval[{2,4}]] == \ Interval[] does *not* return False but rather leaves it undetermined. This seems incorrect to me under either interpretation of Interval[]. Can anyone justify this? In any case, my workaround is to instead use: Min[IntervalIntersection[Interval[{0,1}], Interval[{2,4}]]] == \ Infinity which behaves consistently. This turns out to be more than twice as fast as actually comparing endpoints for overlap. P.S. You know what would be nice? The option to define end points as exclusive, e.g. [2,4) which might be defined as Interval[{2,4},Exclusive->Max]. -- Andy > [...] >> For example evaluate >> >> f[x_] := x^2 + x >> f[Interval[{-1, 1}]] >> >> and you get >> >> Interval[{-1, 2}] >> >> which is not really very good. > [...] > > Intervals are assumed to be independent, say, like two independent > variables. Therefore, what Mathematica computes in your example is > > In[1]:= Interval[{-1, 1}]^2 + Interval[{-1, 1}] > > Out[1]= Interval[{-1, 2}] > > You could think of the endpoints of the resulting interval as being > the > min and max values of a function of two variables over the region > -1<=x|y<=1. > > In[2]:= Minimize[{x^2 + y, -1 <= x <= 1, -1 <= y <= 1}, {x, y}] > > Out[2]= {-1, {x -> 0, y -> -1}} > > In[3]:= Maximize[{x^2 + y, -1 <= x <= 1, -1 <= y <= 1}, {x, y}] > > Out[3]= {2, {x -> -1, y -> 1}} > > This also explains the difference between x^2 (one variable) and x*x > which is rally computed as x*y (two independent variables). > > In[4]:= Minimize[{x*y, -1 <= x <= 1, -1 <= y <= 1}, {x, y}] > > Out[4]= {-1, {x -> -1, y -> 1}} > > In[5]:= Maximize[{x*y, -1 <= x <= 1, -1 <= y <= 1}, {x, y}] > > Out[5]= {1, {x -> -1, y -> -1}} > > --Jean-Marc > === Subject: Eigensystem[hermitianMatrix] sometimes returns non-orthonormal In Mathematica 7.0.0 (for Linux), calling Eigenvectors[H] or Eigensystem[H] for a numerical Hermitian matrix H sometimes returns eigenvectors that are not orthonormal. This happens when some eigenvalues are degenerate. (I can supply example code that illustrates the problem, if necessary.) This is not really a bug -- the documentation for Eigensystem[] doesn't \ make any guarantees of orthonormality -- but nevertheless it is an annoying part of Mathematica's design. This issue has been raised 11 years ago ( http://forums.wolfram.com/mathgroup/archive/1998/Mar/msg00418.html ), but that post is corrupted! (Surely Wolfram isn't resorting to censorship?) I was hoping that in Mathematica 7 I would be able to write something like Eigensystem[H, Method->\LAPACK-ZHEEVR\] or Eigensystem[H, OrthonormalizeEigenvectors->True] but no such options seem to exist. One workaround is to apply Orthogonalize[] to the matrix of eigenvectors, but the documentation for Orthogonalize[] doesn't guarantee that the orthonormalization will only occur within the \degenerate subspace\. So one has to resort to \ complicated fixes (e.g., http://arxiv.org/pdf/hep-ph/9607313 ). Does anyone have a simpler solution? (For example, is there an easy way to call LAPACK'S ZHEEVR routine, which guarantees orthornormal eigenvectors, from Mathematica?) Yen Lee Loh === Subject: Graphics export for high quality documents Graphics export for high quality documents I am working on a book project where I have a number of graphics, and some tables that I want to create using Mathematica. There are a number of problems that I have found with this. I am using Mathematica 7.0 on Windows 64 bit, in case that matters. It is hard to get high quality output into Microsoft Word. If I export graphics as WMF or EMF the text frequently look funny - there is a character layout issue. I think this has to do with how Mathematica deals with spacing and scaling. Setting ImageSize helps, and using the right font names helps, but there still are problems. Another problem is that PDF files of a Word document that includes Mathematica graphics imported as EMF often has problems with mathematical symbols. Exporting PDF directly from Mathematica is in general higher quality than WMF, EMF output. However, it has the problem that you can't import it into Microsoft Word - at least not directly. There might some way to process it so you can. Also, there seem to be some persistent problems with PDFs- the mathematical symbol fonts do not seem to work reliably for me. Part of the problem is a bug/feature in Mathematica that it does not embed fonts in the PDF. The work around is to run a PDF distiller program over the output to embed the fonts which helps. PDFs from Mathematica can be edited with Adobe Illustrator, which helps touch them up if there is something I can't achieve in Mathematica directly. Again, there are problems with math fonts - even on the same computer if I edit a graph that has Traditional Form output, the math symbols won't appear in Illustrator. For use in the book we want to import the pictures into Adobe InDesign. I am not an InDesign user, but when I have tried to import PDFs from Mathematica using the Place command, what I get looks like a scaled, low res bitmap. The book publishing / design / layout people that I have spoken with so far all want me to export raw data so the graphs can be made with other software - they have no experience with Mathematica. Yet many people seem to do books with Mathematica so this must be a solved problem. Tables are another issue - with the Grid[] you can make some pretty complicated tables. But they are hard to export to other programs that will treat them like tables instead of like pictures. EMF and PDF work, but with the same problems as Graphics output. It has occurred to me that HTML or XML output might help for tables. Finally, I know that a lot of people use 3rd party add-ons when they make publication quality graphs with Mathematica. The Presentations package by David Park is one such - which I already have, but I have only used for a few things and don't claim to know all it can do. There are/were several packages on MathSource for doing custom tick marks and other things - they probably are still there but they have reorganized MathSource to a state where I can't find them anymore, even with search. Are there any other add-ons that are useful for publication quality graphics? Or stand alone programs I can use to post-process things exported from Mathematica? Surely somebody out there must have experience with this! Here are my specific questions: 1. What is the best strategy for Export[] for graphics for use in Microsoft Word? Export to EMF? Something else? 2. What is the best strategy for Export[] to import into InDesign or other desktop publishing programs? Export to PDF, followed by running though batch PDF distiller is my best hope at the moment. 3. What are the most useful Mathematica add-ons, or stand alone programs for making publication quality charts and graphics? Nathan This message and any attachments, may contain confidential and/or legally privileged information. If you are not the intended recipient of the message by the original sender, please destroy it. Message and attachments copyright (c) 2008, all rights reserved. Any unauthorized dissemination, distribution or copying is strictly forbidden === Subject: Creating TOC with Mathematica 7 Hello all, I'm writing a larger document with Mathematica 7 (stylesheet book) and \ have the problem of creating a table of contents. I tried the Author tools, WRI support told me this should work with version 7... but I only get error messages.Can anyone give me an hint how to produce a TOC (and an index)? Mike === Subject: Inverse of a Big Matrix Hello everyone, I'm computing the inverse of a big matrix, 500 x 500. Well, maybe not that big, but I'm getting the error message \General::luc: Result for `1` of badly conditioned matrix `2` may \ contain significant numerical errors. >>\ and I'm wondering if anyone can suggest a workaround. All I can say is that the determinant is very small (-4.327475016428501*10^-1947), and that I can compute the inverse of various submatrices of size 100 x100. Gregory === Subject: Re: Difference Fit vs. Correlation >get 0.514093. How come? >In[60]:= lm = LinearModelFit[GaltonDat, {1, x}, x] >In[62]:= lm[\BestFit\] >Out[62]= 33.8866 + 0.514093 x >In[63]:= r2 = Correlation[GaltonX, GaltonY] >Out[63]= 0.501338 You seem to expect the slope of the best fit line to have the same value as the correlation between x and y. These are two separate things and will never have the same value with real data. The slope of the best fit line is given by Covariance[x,y]/Variance[y] The correlation between x and y (Pearson's correlation) is given by Covariance[x,y]/Sqrt[ Variance[x] Variance[y] ] The only case where the slope and correlation have the same value is the trivial case where x = y and there is no error term, i.e., perfect correlation with a slope of 1. === Subject: Re: listing user defined, independent variables > > > > I have a notebook in which there are over 1300 variables (symbols) \ defined. > The vast majority of these are dependent variables. I can get a list of \ them > all with Names[\Global`*\], but what I really want is a list of only \ the > independent variables. Is there any obvious way to do this? Mathematica \ must > \know\ which variables are functions of other symbols, so I was hoping \ that > there would be an \attribute\ of a dependent variable that I could use \ as a > filter on Names[]. Any thoughts? I am using V5.1. I don't think that there is an attribute for that information. The internals of mathematica are mostly rule based, and OwnValues[] will give you the information which can be used to determine the dependencies that you are seeking. I could only think about a rather involved way to extract that information, since you need to be careful to not evaluate too early. The following is an approach to determine the dependencies: (*ensure that we can see the symbols, not only the values:*) SetAttributes[dependentQ, HoldFirst] (* if we get a symbol which has an OwnValue, extract the unevaluated RHS of its OwnValue and see whether it contains symbols from the Global context: *) dependentQ[var_Symbol] := If[TrueQ[Length[OwnValues[var]] > 0], Not[FreeQ[Extract[OwnValues[var], {1, 2}, Hold], s_Symbol /; Context[s] == \Global`\]], False ] (* as a filter for variable names, it is handy if we accept strings as arguments, too: *) dependentQ[name_String] := dependentQ @@ ToExpression[name, InputForm, Hold] (* use as filter: *) Select[Names[\Global`*\], dependentQ] It might well be that there are simpler and/or more efficient ways to do this, but I can't think of one now and it should be a starting point... hth, albert === Subject: Re: listing user defined, independent variables Paul The Mathematica command ValueQ[] might be useful for you. For example if \ you start a new Mathematica and define: a=b+c After that, if you evaluate ValueQ[a] you obtain True, while the evaluation of ValueQ[b] gives False. HTH Jose Mexico -----Mensaje original----- De: Paul Ellsmore [mailto:paul.ellsmore@nanion.co.uk] Enviado el: Martes, 24 de Febrero de 2009 04:44 Para: mathgroup@smc.vnet.net Asunto: listing user defined, independent variables I have a notebook in which there are over 1300 variables (symbols) defined. The vast majority of these are dependent variables. I can get a list of \ them all with Names[\Global`*\], but what I really want is a list of only the independent variables. Is there any obvious way to do this? Mathematica \ must \know\ which variables are functions of other symbols, so I was hoping \ that there would be an \attribute\ of a dependent variable that I could use as \ a filter on Names[]. Any thoughts? I am using V5.1. Paul Dr. Paul A. Ellsmore Nanion Limited Oxford Centre for Innovation Mill Street Oxford United Kingdom OX2 0JX Tel: +44 (0) 1865 811175 Fax: +44 (0) 1865 248594 === Subject: Re: listing user defined, independent variables a) what mean \Mathematica must 'know' which variables are functions of other symbols\. Variables functions of other symbols ?? what should that be ?? b) Start a fresh kernel and type blub[x_] := Module[{y, z}, x] and Names[\Global`*\] gives {\blub\, \x\, \x$\, \y\, \y$\, \z\, \z$\} The \*$\ symbols come from the Module[] and have th attribute Temporary and the \blub\ function has an DownValue[]. Since x,y,z appear in the down values of blub[] it is not possible to find out if there is also a global symbol with a that has the name \x\, \y\ or \z\. Jens > > > > I have a notebook in which there are over 1300 variables (symbols) \ defined. > The vast majority of these are dependent variables. I can get a list of \ them > all with Names[\Global`*\], but what I really want is a list of only \ the > independent variables. Is there any obvious way to do this? Mathematica \ must > \know\ which variables are functions of other symbols, so I was hoping \ that > there would be an \attribute\ of a dependent variable that I could use \ as a > filter on Names[]. Any thoughts? I am using V5.1. > > > > > > > Paul > > > > Dr. Paul A. Ellsmore > > > > Nanion Limited > > Oxford Centre for Innovation > > Mill Street > > Oxford > > United Kingdom > > OX2 0JX > > > > Tel: +44 (0) 1865 811175 > > Fax: +44 (0) 1865 248594 > > === Subject: Re: DiscretePlot ... > However, unlike ListPlot (which has Joined->False by default), > DiscretePlot has Joined->Automatic by default. If we plot greater than > 149 points with DiscretePlot, Mathematica joins the points, and it's a > royal mess. ...[examples of the mess condense down to]... DiscretePlot[Sum[(-1)^(n + 1)/n, {n, 1, k}], {k, 1, 150}] DiscretePlot[Sin[n], {n, 0, 500}] >... > We can turn off the filling. (I like the filling sometimes, but not always.) >... > The students are having trouble remembering to do this, though, and I >... > I'd be far happier if DiscretePlot had Joined->False by default. Mathematica allows you to set the option defaults to meet your needs. Just SetOptions once per session and be done with it: In[1]:= Options[DiscretePlot, {Filling, Joined}] Out[1]= {Filling -> Axis, Joined -> Automatic} In[2]:= SetOptions[DiscretePlot, Filling -> None, Joined -> False]; In[3]:= Options[DiscretePlot, {Filling, Joined}] Out[3]= {Filling -> None, Joined -> False} Q.E.D === Subject: HoldForm[1*2*3] should give 1 x 2 x 3 not 2 x 3 HoldForm[] is loosing the 1* when it apparently should not: In[1]:= HoldForm[1*2*3] Out[1]= 2 x 3 In[2]:= HoldForm[1*1*1] Out[2]= 1 x 1 x 1 In[3]:= HoldForm[3*2*1] Out[3]= 3 x 2 In[4]:= HoldForm[2*2*2] Out[4]= 2 x 2 x 2 In[5]:= HoldForm[2*1*3] Out[5]= 2 x 3 In[6]:= HoldForm[1*2] Out[6]= 1 x 2 In[7]:= HoldForm[1*2*1] Out[7]= 1 x 2 x 1 Q.E.D. === Subject: Re: newbie: programmatic sequence of plots? > How to get a programmatic sequence of plots? > === > As advertised by the Subject:, I'm new to Mathematica (specifically > 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any > lapses in terminology. I'd also appreciate pointers to specific docs > rather than just an RTFM. > > Since I'm currently unable to model the logistic map y=a y (1-y) (see > previous post) I'm trying to do a series of plots of it, to see how > behavior changes over time. I can get a plot of a single instance with > > Clear[a,y,y0,nRecurr]; > a=3.5; > y0=0.4; > nRecurr=50; > ListPlot[ > RecurrenceTable[{y[n+1]==a y[n] (1-y[n]),y[0]==y0}, > y,{n,1,nRecurr}],Joined->True > ] > > I can get a sequence of tables of values with > > Clear[a, y, y0, nRecurr, yinit, yinc, yfinal]; > a = 3.5; > nRecurr = 50; > yinit = 0.1; > yinc = 0.01; > yfinal = 0.2; > For[y0 = yinit, y0 <= yfinal, y0 += yinc, Print[y0, \:\\n\, > RecurrenceTable[{y[n + 1] == a y[n] (1 - y[n]), y[0] == y0}, = y, {n, > 1, nRecurr}]]] > > But when I try to plot those values with > > Clear[a, y, y0, nRecurr, yinit, yinc, yfinal]; > a = 3.5; > nRecurr = 50; > yinit = 0.1; > yinc = 0.01; > yfinal = 0.2; > For[y0 = yinit, y0 <= yfinal, y0 += yinc, > ListPlot[ > RecurrenceTable[ > {y[n + 1] == a y[n] (1 - y[n]), y[0] == y0}, y, {n, 1= , nRecurr} > ] > ,Joined->True] > ] > > I get absolutely nothing: no plot, no error message, no nada. > Similarly, when I try to plot the difference between two runs of the > map with > > seqDiff[a_,y_,inc_]:=Module[ > {r=y,s=y+inc}, > ListPlot[ > Table[r=a r (1-r),{50}]-Table[s=a s (1-s),{50}], > Joined->True,PlotRange->{-1,1} > ] > ] > seqDiff[4.0,0.3,0.1] > > I get a plot. But when I try to put that inside a for loop > > Clear[a, i,init,inc,final]; > a = 4.0; > init=0.3; > inc=0.1; > final=0.5; > For[i=init,i<=final,i+=inc,seqDiff[a,i,inc]] > > I get nothing: no plot, no error message. > > What am I doing wrong? How to get a series of plots? > > TIA, Tom Roche Hello Tom, I think the reason for getting no graphics output ist, that your code produces graphics-objects and these are not shown in this loop. To show them you could do it like this: gatheriong the objects in a bag and showing at the end o calculation (it=B4s a quick and dirty modification of your code - I know - this could be done much more elgenatly, eg. with an own Module). Clear[a, y, y0, nRecurr, yinit, yinc, yfinal]; a = 3.5; nRecurr = 50; yinit = 0.1; yinc = 0.01; yfinal = 0.2; out = {}; (* modification here *) For[y0 = yinit, y0 <= yfinal, y0 += yinc, AppendTo[out, (* modification here *) ListPlot[ RecurrenceTable[{y[n + 1] == a y[n] (1 - y[n]), y[0] == y0}, y, {n, 1, nRecurr}]]]; ]; out (* modification here *) Have you seen the excellent example of the logisitc map in the help referring to the function RecurrenceTable (-> bifurcation of the logistic map)? Mike === Subject: Re: newbie: programmatic sequence of plots? > How to get a programmatic sequence of plots? > === > As advertised by the Subject:, I'm new to Mathematica (specifically > 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any > lapses in terminology. I'd also appreciate pointers to specific docs > rather than just an RTFM. > > Since I'm currently unable to model the logistic map y=a y (1-y) (see > previous post) I'm trying to do a series of plots of it, to see how > behavior changes over time. I can get a plot of a single instance with > > Clear[a,y,y0,nRecurr]; > a=3.5; > y0=0.4; > nRecurr=50; > ListPlot[ > RecurrenceTable[{y[n+1]==a y[n] (1-y[n]),y[0]==y0}, > y,{n,1,nRecurr}],Joined->True > ] > > I can get a sequence of tables of values with > > Clear[a, y, y0, nRecurr, yinit, yinc, yfinal]; > a = 3.5; > nRecurr = 50; > yinit = 0.1; > yinc = 0.01; > yfinal = 0.2; > For[y0 = yinit, y0 <= yfinal, y0 += yinc, Print[y0, \:\\n\, > RecurrenceTable[{y[n + 1] == a y[n] (1 - y[n]), y[0] == y0}, y, {n, > 1, nRecurr}]]] > > But when I try to plot those values with > > Clear[a, y, y0, nRecurr, yinit, yinc, yfinal]; > a = 3.5; > nRecurr = 50; > yinit = 0.1; > yinc = 0.01; > yfinal = 0.2; > For[y0 = yinit, y0 <= yfinal, y0 += yinc, > ListPlot[ > RecurrenceTable[ > {y[n + 1] == a y[n] (1 - y[n]), y[0] == y0}, y, {n, 1, nRecurr} > ] > ,Joined->True] > ] > > I get absolutely nothing: no plot, no error message, no nada. > Similarly, when I try to plot the difference between two runs of the > map with > > seqDiff[a_,y_,inc_]:=Module[ > {r=y,s=y+inc}, > ListPlot[ > Table[r=a r (1-r),{50}]-Table[s=a s (1-s),{50}], > Joined->True,PlotRange->{-1,1} > ] > ] > seqDiff[4.0,0.3,0.1] > > I get a plot. But when I try to put that inside a for loop > > Clear[a, i,init,inc,final]; > a = 4.0; > init=0.3; > inc=0.1; > final=0.5; > For[i=init,i<=final,i+=inc,seqDiff[a,i,inc]] > > I get nothing: no plot, no error message. > > What am I doing wrong? How to get a series of plots? Just do what you did with the tables: Print the plots. You should understand that plots are no different than any other expression in Mathematica and only when returned as output, Mathematica knows how to format them. Since your For loop never returns anything, nothing is shown, just as you would expect for other expressions, too. Note that this has changed from version 5.2 to version 6. Another hint: Using Do instead of For leads to code which is easier to understand and less error prone. It also has the advantage that the syntax is exactly like that of Table which would return a list of these plots additionaly or instead of just printing them, so that you can use ListAnimation or TabView or whatever you like for displaying them. hth, albert === Subject: Re: newbie: programmatic sequence of plots? The problem is to get some visible effect from the execution of the body of the For loop. Try replacing the whole ListPlot function with just the variable y0. Would that give you a set of printed y0 values? No, unless you use Print. Well, Print works for ListPlots as well. Loops themselves only have a null return value. In versions before 6, the showing of a plot after a Plot function was a side effect, like a hidden Print function and it couldn't be suppressed with a semicolon. The main effect was the generation of a graphics structure (for use in assignments and Show and so). In 6 and 7 this behaviour has been changed and the generation of a directly displayable Graphics structure is now the main (and only) effect. It can be supressed by a semicolon and when generated in a loop it has to be explicitely printed if visibility is desired. > How to get a programmatic sequence of plots? > === > As advertised by the Subject:, I'm new to Mathematica (specifically > 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any > lapses in terminology. I'd also appreciate pointers to specific docs > rather than just an RTFM. > > Since I'm currently unable to model the logistic map y=a y (1-y) (see > previous post) I'm trying to do a series of plots of it, to see how > behavior changes over time. I can get a plot of a single instance with > > Clear[a,y,y0,nRecurr]; > a=3.5; > y0=0.4; > nRecurr=50; > ListPlot[ > RecurrenceTable[{y[n+1]==a y[n] (1-y[n]),y[0]==y0}, > y,{n,1,nRecurr}],Joined->True > ] > > I can get a sequence of tables of values with > > Clear[a, y, y0, nRecurr, yinit, yinc, yfinal]; > a = 3.5; > nRecurr = 50; > yinit = 0.1; > yinc = 0.01; > yfinal = 0.2; > For[y0 = yinit, y0 <= yfinal, y0 += yinc, Print[y0, \:\\n\, > RecurrenceTable[{y[n + 1] == a y[n] (1 - y[n]), y[0] == y0}, = y, {n, > 1, nRecurr}]]] > > But when I try to plot those values with > > Clear[a, y, y0, nRecurr, yinit, yinc, yfinal]; > a = 3.5; > nRecurr = 50; > yinit = 0.1; > yinc = 0.01; > yfinal = 0.2; > For[y0 = yinit, y0 <= yfinal, y0 += yinc, > ListPlot[ > RecurrenceTable[ > {y[n + 1] == a y[n] (1 - y[n]), y[0] == y0}, y, {n, 1= , nRecurr} > ] > ,Joined->True] > ] > > I get absolutely nothing: no plot, no error message, no nada. > Similarly, when I try to plot the difference between two runs of the > map with > > seqDiff[a_,y_,inc_]:=Module[ > {r=y,s=y+inc}, > ListPlot[ > Table[r=a r (1-r),{50}]-Table[s=a s (1-s),{50}], > Joined->True,PlotRange->{-1,1} > ] > ] > seqDiff[4.0,0.3,0.1] > > I get a plot. But when I try to put that inside a for loop > > Clear[a, i,init,inc,final]; > a = 4.0; > init=0.3; > inc=0.1; > final=0.5; > For[i=init,i<=final,i+=inc,seqDiff[a,i,inc]] > > I get nothing: no plot, no error message. > > What am I doing wrong? How to get a series of plots? > > TIA, Tom Roche === Subject: Re: newbie: can't Manipulate ListPlot of recurrence Hi Tom, you can not use y for two things, table-generator and Manupulate-variable. Here is the corrected version: Manipulate[ ListPlot[(y = y0; Table[y = a y (1 - y), {50}]), Joined -> True], {{a, 3.5}, 0, 4}, {{y0, 0.4}, 0, 1}] Daniel > summary: I'm trying to Manipulate the logistic map. I can ListPlot it, > but when I try to Manipulate, the UI behaves weirdly. > > details: > === > As advertised by the Subject:, I'm new to Mathematica (specifically > 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any > lapses in terminology. I'd also appreciate pointers to specific docs > rather than just an RTFM. > > I'm trying to model the logistic map y=a y (1-y): > > http://en.wikipedia.org/wiki/Logistic_map > http://mathworld.wolfram.com/LogisticMap.html > http://www.phy.duke.edu/~palmer/notebooks/LogisticMap.nb > > To start with I just tried to plot it, which works: > > Clear[a, y]; > a=3.5; > y=0.4; > ListPlot[Table[y=a y (1-y),{50}],Joined->True] > > I'd like to Manipulate a and y, but when I try to > > Clear[a, y]; > Manipulate[ > ListPlot[Table[y=a y (1-y),{50}],Joined->True], {{a, 3.5}, 0, 4}, > {{y, 0.4}, 0, 1}] > > I get weird behavior: > > 1 initially the y slider oscillates > > 2 initially the plot displays but flashes (apparently between two > phases) until I click one of the sliders > > 3 the y slider will not move > > 4 the a slider can be dragged, but to no effect (i.e. the plot does > not change) > > 5 there are no error messages > > What am I doing wrong? and how can I Manipulate this map? > > TIA, Tom Roche > === Subject: Re: newbie: can't Manipulate ListPlot of recurrence > summary: I'm trying to Manipulate the logistic map. I can ListPlot it, > but when I try to Manipulate, the UI behaves weirdly. > > details: > === > As advertised by the Subject:, I'm new to Mathematica (specifically > 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any > lapses in terminology. I'd also appreciate pointers to specific docs > rather than just an RTFM. > > I'm trying to model the logistic map y=a y (1-y): > > http://en.wikipedia.org/wiki/Logistic_map > http://mathworld.wolfram.com/LogisticMap.html > http://www.phy.duke.edu/~palmer/notebooks/LogisticMap.nb > > To start with I just tried to plot it, which works: > > Clear[a, y]; > a=3.5; > y=0.4; > ListPlot[Table[y=a y (1-y),{50}],Joined->True] > > I'd like to Manipulate a and y, but when I try to > > Clear[a, y]; > Manipulate[ > ListPlot[Table[y=a y (1-y),{50}],Joined->True], {{a, 3.5}, 0, 4}, > {{y, 0.4}, 0, 1}] > > I get weird behavior: > > 1 initially the y slider oscillates > > 2 initially the plot displays but flashes (apparently between two > phases) until I click one of the sliders > > 3 the y slider will not move > > 4 the a slider can be dragged, but to no effect (i.e. the plot does > not change) all these come from the fact that you are asigning to y which is one of the variables that you want to manipulate, which is almost never a good idea... > 5 there are no error messages > What am I doing wrong? and how can I Manipulate this map? I think this does what you want: Clear[a, y]; Manipulate[ ListPlot[ Block[{x = y}, Table[x = a x (1 - x), {50}] ], Joined -> True, PlotRange -> {0, 1} ], {{a, 3.5}, 0, 4}, {{y, 0.4}, 0, 1} ] hth, albert === Subject: Re: newbie: can't Manipulate ListPlot of recurrence The problem is that each change in y (being one of the tracked variables) is a trigger for another round of calculations, which again changes y and triggers again, ad infinitum. One solution would be the use of RecurrenceTable instead of Table which enables you to use y as the initial condition only and to specify the map using a different variable. Now y itself is not changed due to the calculation and no additional trigger occurs: Clear[a, y]; Manipulate[ ListPlot[RecurrenceTable[{yy[n + 1] == a yy[n] (1 - yy[n]), yy[0] == y}, yy, {n, 50}], Joined -> True], {{a, 3.5}, 0, 4}, {{y, 0.4}, 0, 1}] > summary: I'm trying to Manipulate the logistic map. I can ListPlot it, > but when I try to Manipulate, the UI behaves weirdly. > > details: > === > As advertised by the Subject:, I'm new to Mathematica (specifically > 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any > lapses in terminology. I'd also appreciate pointers to specific docs > rather than just an RTFM. > > I'm trying to model the logistic map y=a y (1-y): > > \ http://en.wikipedia.org/wiki/Logistic_maphttp://mathworld.wolfram.com/Log= isticMap.htmlhttp://www.phy.duke.edu/~palmer/notebooks/LogisticMap.nb > > To start with I just tried to plot it, which works: > > Clear[a, y]; > a=3.5; > y=0.4; > ListPlot[Table[y=a y (1-y),{50}],Joined->True] > > I'd like to Manipulate a and y, but when I try to > > Clear[a, y]; > Manipulate[ > ListPlot[Table[y=a y (1-y),{50}],Joined->True], {{a, 3.5}, 0, 4}= , > {{y, 0.4}, 0, 1}] > > I get weird behavior: > > 1 initially the y slider oscillates > > 2 initially the plot displays but flashes (apparently between two > phases) until I click one of the sliders > > 3 the y slider will not move > > 4 the a slider can be dragged, but to no effect (i.e. the plot does > not change) > > 5 there are no error messages > > What am I doing wrong? and how can I Manipulate this map? > > TIA, Tom Roche === Subject: Re: newbie: can't Manipulate ListPlot of recurrence There seem to be several...maybe you could start from one of these: http://demonstrations.wolfram.com/search.html?query=logistic HTH. Roger Williams Franklin Laboratory > summary: I'm trying to Manipulate the logistic map. I can ListPlot it, > but when I try to Manipulate, the UI behaves weirdly. > > details: > === > As advertised by the Subject:, I'm new to Mathematica (specifically > 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any > lapses in terminology. I'd also appreciate pointers to specific docs > rather than just an RTFM. > > I'm trying to model the logistic map y=a y (1-y): > > \ http://en.wikipedia.org/wiki/Logistic_maphttp://mathworld.wolfram.com/Log= isticMap.htmlhttp://www.phy.duke.edu/~palmer/notebooks/LogisticMap.nb > > To start with I just tried to plot it, which works: > > Clear[a, y]; > a=3.5; > y=0.4; > ListPlot[Table[y=a y (1-y),{50}],Joined->True] > > I'd like to Manipulate a and y, but when I try to > > Clear[a, y]; > Manipulate[ > ListPlot[Table[y=a y (1-y),{50}],Joined->True], {{a, 3.5}, 0, 4}= , > {{y, 0.4}, 0, 1}] > > I get weird behavior: > > 1 initially the y slider oscillates > > 2 initially the plot displays but flashes (apparently between two > phases) until I click one of the sliders > > 3 the y slider will not move > > 4 the a slider can be dragged, but to no effect (i.e. the plot does > not change) > > 5 there are no error messages > > What am I doing wrong? and how can I Manipulate this map? > > TIA, Tom Roche === Subject: Re: newbie: can't Manipulate ListPlot of recurrence [...] > Clear[a, y]; > a=3.5; > y=0.4; > ListPlot[Table[y=a y (1-y),{50}],Joined->True] [...] Clear[a, y]; Manipulate[ ListPlot[Table[y=a y (1-y),{50}],Joined->True], {{a, 3.5}, 0, 4}, {{y, 0.4}, 0, 1}] > What am I doing wrong? and how can I Manipulate this map? What you're doing wrong is changing the values of the variable y while you compute the successive values of your logistic map. Manipulate wants to \ reflect the current value of y in its position along the control slider, and y bounces back and forth. Now, there are quite a few ways to get around this, \ but instead of a workaround, I think you're better off using the kernel function \ that's intended to be used with iterated maps like this one: NestList. Rest@NestList[a*#*(1-#)&, y, 50] will produce the same list of values as your Table expression, but y will \ not have its value modified. NestList will put the initial value (with 0 \ function applications) as the first element in the returned list, and Rest \ will get rid of it. If you stick that in your Mainpulate, it should just work. Pillsy === Subject: Re: newbie: can't Manipulate ListPlot of recurrence you doing almost everything wrong. You mean Manipulate[ ListPlot[ NestList[a # (1 - #) &, y, 50]], {{a, 3.5}, 0, 4}, {{y, 0.4}, 0, 1}] Atleast the assigment y=a y (1-y) in the ListPlot[] command will change you y value on and on and so it is no wonder that the slider is unmovable and moves unexpected. Jens > summary: I'm trying to Manipulate the logistic map. I can ListPlot it, > but when I try to Manipulate, the UI behaves weirdly. > > details: > === > As advertised by the Subject:, I'm new to Mathematica (specifically > 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any > lapses in terminology. I'd also appreciate pointers to specific docs > rather than just an RTFM. > > I'm trying to model the logistic map y=a y (1-y): > > http://en.wikipedia.org/wiki/Logistic_map > http://mathworld.wolfram.com/LogisticMap.html > http://www.phy.duke.edu/~palmer/notebooks/LogisticMap.nb > > To start with I just tried to plot it, which works: > > Clear[a, y]; > a=3.5; > y=0.4; > ListPlot[Table[y=a y (1-y),{50}],Joined->True] > > I'd like to Manipulate a and y, but when I try to > > Clear[a, y]; > Manipulate[ > ListPlot[Table[y=a y (1-y),{50}],Joined->True], {{a, 3.5}, 0, 4}, > {{y, 0.4}, 0, 1}] > > I get weird behavior: > > 1 initially the y slider oscillates > > 2 initially the plot displays but flashes (apparently between two > phases) until I click one of the sliders > > 3 the y slider will not move > > 4 the a slider can be dragged, but to no effect (i.e. the plot does > not change) > > 5 there are no error messages > > What am I doing wrong? and how can I Manipulate this map? > > TIA, Tom Roche > === Subject: Re: question related to (-1)^(1/3) As pointed out previously, you do not want x^(1/3) (which is by definition a \ complex number for negative x), you want the real solution to y^3 == x. The \ real solution to this equation is Sign[x]*Abs[x]^(1/3) Assuming[{Element[x, Reals]}, Simplify[Reduce[ (Sign[x]*Abs[x]^(1/3))^3 == x]]] True r[x_] := Sign[x]*Abs[x]^(1/3) Plot[r[x], {x, -8, 8}] Bob Hanlon I just want to get the real solution of (-1)^(1/3). BTW, I have read the tutorial but I am still confused with its explanation. But that is not important, I just feel it is inconvenient for the following problem: RecurrenceTable[{x[n + 1] == -x[n]^(1/3), x[0] == 1}, x, {n, 1, 200}] // N I consider there should be a way to limit the output in the domain real. for example, in MAXIMA (%i1) domain; (%o1) real (%i2) (-1)^(1/3); (%o2) -1 (%i3) domain:complex; (%o3) complex (%i4) (-1)^(1/3),numer; (%o4) 0.86602540378444*%i+0.5 > This misunderstanding pops up over and over again in this group. > Please type tutorial/FunctionsThatDoNotHaveUniqueValues in the search > bar of the mathematica doc centre. > === Subject: Re: Exporting data into a file, OpenWrite no double-slashes for me thank you very much - I've got a Mac. 2009/2/24 Sjoerd C. de Vries : > >> When you use Export, the file will be created in the current >> working directory. > > I might add \...unless you include the full path to the file in the > filename (using double slashes to separate directories and files, as a > slash is used as an escape character in strings)\ > > > > === Subject: Re: newbie: how to define, typeset a multi-rule function? Piecewise[] ?? Jens === > As advertised by the Subject:, I'm new to Mathematica (specifically > 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any > lapses in terminology. I'd also appreciate pointers to specific docs > rather than just an RTFM. I suspect in this case I just need to know > what the appropriate term is for what I'm trying to create. However > I've tried searching the docs for various permutations of multi-rule > or multi-line function, and even googling, to no avail. > > I'm trying to create a notebook that typesets a particular > mathematical function, and then solves it. The function has 2 parts or > rules: it returns k (a constant) for one part of its domain, and 0 > otherwise. This is typically typeset with the function name and the > equals sign on one line, then a large left curly bracket (or brace) > centered on that line, then each rule on a separate line with all the > rule lines to the right of the bracket. For an example in a math > layout, I can almost typeset the function in OpenOffice Math like > > f_x(%chi) = left lbrace stack {k if %chi in [0,1] # 0 otherwise} right > rbrace > > (except that I don't want the closing brace, but that's another > problem). I tried to create this using the palettes, but I didn't see > one that did multiline brackets. What do I need to use? > > Once I've typeset this function, I want to actually solve it. How does > one create a function with multiple rules in Mathematica? > > TIA, Tom Roche > === Subject: Re: newbie: how to define, typeset a multi-rule function? Hi Tom, for piecewise defined functiom there is \Piecewise\. In your case: Piecewise[{{1,0<=x<1}},0] But you may achieve the same with conditional function definitions: fun[x_]=0 fun[x_]/;0<=x<1 =1 here more specific function definitions override less specific ones. hope this helps, Daniel === > As advertised by the Subject:, I'm new to Mathematica (specifically > 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any > lapses in terminology. I'd also appreciate pointers to specific docs > rather than just an RTFM. I suspect in this case I just need to know > what the appropriate term is for what I'm trying to create. However > I've tried searching the docs for various permutations of multi-rule > or multi-line function, and even googling, to no avail. > > I'm trying to create a notebook that typesets a particular > mathematical function, and then solves it. The function has 2 parts or > rules: it returns k (a constant) for one part of its domain, and 0 > otherwise. This is typically typeset with the function name and the > equals sign on one line, then a large left curly bracket (or brace) > centered on that line, then each rule on a separate line with all the > rule lines to the right of the bracket. For an example in a math > layout, I can almost typeset the function in OpenOffice Math like > > f_x(%chi) = left lbrace stack {k if %chi in [0,1] # 0 otherwise} right > rbrace > > (except that I don't want the closing brace, but that's another > problem). I tried to create this using the palettes, but I didn't see > one that did multiline brackets. What do I need to use? > > Once I've typeset this function, I want to actually solve it. How does > one create a function with multiple rules in Mathematica? > > TIA, Tom Roche > === Subject: Re: newbie: how to define, typeset a multi-rule function? === > As advertised by the Subject:, I'm new to Mathematica (specifically > 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any > lapses in terminology. I'd also appreciate pointers to specific docs > rather than just an RTFM. I suspect in this case I just need to know > what the appropriate term is for what I'm trying to create. However > I've tried searching the docs for various permutations of multi-rule > or multi-line function, and even googling, to no avail. > > I'm trying to create a notebook that typesets a particular > mathematical function, and then solves it. The function has 2 parts or > rules: it returns k (a constant) for one part of its domain, and 0 > otherwise. This is typically typeset with the function name and the > equals sign on one line, then a large left curly bracket (or brace) > centered on that line, then each rule on a separate line with all the > rule lines to the right of the bracket. For an example in a math > layout, I can almost typeset the function in OpenOffice Math like > > f_x(%chi) = left lbrace stack {k if %chi in [0,1] # 0 otherwise} right > rbrace > > (except that I don't want the closing brace, but that's another > problem). I tried to create this using the palettes, but I didn't see > one that did multiline brackets. What do I need to use? > > Once I've typeset this function, I want to actually solve it. How does > one create a function with multiple rules in Mathematica? I think what you want is Piecewise. It formats as you want and can also be input the way you want, which is described in the documentation for Piecewise. Piecewise functions can be handled by many mathematica functions, so I think you can then \solve it\, whatever solving a function might mean to you... hth, albert === Subject: Re: newbie: how to define, typeset a multi-rule function? Tom Roche Feb 24, 5:46 am (rearranged) >> I'm trying to create a notebook that typesets a particular >> mathematical function, and then solves it. I.e. I'll have a line of text that shows the function to solve, then another line of input that solves it when evaluated. Like a homework problem. >> The function has 2 parts or rules: it returns k (a constant) for one >> part of its domain, and 0 otherwise. This is typically typeset with >> the function name and the equals sign on one line, then a large left >> curly bracket (or brace) centered on that line, then each rule on a >> separate line with all the rule lines to the right of the bracket. >> I suspect in this case I just need to know what the appropriate >> term is for what I'm trying to create. However I've tried searching >> the docs for various permutations of multi-rule or multi-line >> function, and even googling, to no avail. > there is \Piecewise\. doh! That's the term I was trying to remember. > In your case: Piecewise[{{k,0<=x<1}},0] Indeed, and I can solve that like part1ex1fn = {Piecewise[{{k \\[Chi], 0 <= \\[Chi] <= 1}}, 0]} Solve[ First[ Integrate[part1ex1fn, {\\[Chi], -\\[Infinity], \\[Infinity]}] ] == 1, k ] (though I assume there's a better way). But how to layout the equation as text? >> For an example in a math layout, I can almost typeset the function >> in OpenOffice Math like f_x(%chi) = left lbrace stack {k if %chi in >> [0,1] # 0 otherwise} right rbrace (except that I don't want the >> closing brace, but that's another problem). I tried to create this >> using the palettes, but I didn't see one that did multiline >> brackets. > As you're not speaking \Mathematica\, I'm trying. Ya gotta learn somehow. > perhaps this is the function you want: > Subscript[f, x][chi_] = Piecewise[{{k, 0 <= chi <= 1}}] Yep, that sure looks like it, but ... > I used the \special characters\ palette to enter \\[Chi]. ... where's the palette item to get the left brace? > You can also copy/paste the [line above] to Mathematica, press Enter > to evaluate the line, and the bracketed version should appear. That it does, but it doesn't show the f_x(\\[Chi]); i.e. the right-hand side appears, but not the LHS. How do I get both the LHS and RHS to appear as text? TIA, Tom Roche === Subject: Re: newbie: how to define, typeset a multi-rule function? Piecewise is the name you should look-up. Formatting/entry goes like this: Use Esc pw Esc to enter { and Ctrl +Comma and then Ctrl+Enter for each additional piecewise case === > As advertised by the Subject:, I'm new to Mathematica (specifically > 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any > lapses in terminology. I'd also appreciate pointers to specific docs > rather than just an RTFM. I suspect in this case I just need to know > what the appropriate term is for what I'm trying to create. However > I've tried searching the docs for various permutations of multi-rule > or multi-line function, and even googling, to no avail. > > I'm trying to create a notebook that typesets a particular > mathematical function, and then solves it. The function has 2 parts or > rules: it returns k (a constant) for one part of its domain, and 0 > otherwise. This is typically typeset with the function name and the > equals sign on one line, then a large left curly bracket (or brace) > centered on that line, then each rule on a separate line with all the > rule lines to the right of the bracket. For an example in a math > layout, I can almost typeset the function in OpenOffice Math like > > f_x(%chi) = left lbrace stack {k if %chi in [0,1] # 0 otherwise} right > rbrace > > (except that I don't want the closing brace, but that's another > problem). I tried to create this using the palettes, but I didn't see > one that did multiline brackets. What do I need to use? > > Once I've typeset this function, I want to actually solve it. How does > one create a function with multiple rules in Mathematica? > > TIA, Tom Roche === Subject: Re: newbie: how to define, typeset a multi-rule function? As you're not speaking \Mathematica\, I have to do some guessing, but perhaps this is the function you want: Subscript[f, x][chi_] = Piecewise[{{k, 0 <= chi <= 1}}] \\[Piecewise]k 0<=chi<=1 0 True or Subscript[f, x][\\[Chi]_]=Piecewise[{{k,0<=\\[Chi]<=1}}] \\[Piecewise]k 0<=\\[Chi]<=1 0 True In the second version I used the \special characters\ palette to enter \\[Chi]. To enter Subscript[f, x], just type f, then Ctrl-_x. (That does NOT make the function depend on x. It simply makes x part of the function name.) You can also copy/paste the first line to Mathematica, press Enter to evaluate the line, and the bracketed version should appear. > Once I've typeset this function, I want to actually solve it. No clue what that means. In mathematics we solve equations/conditions... not functions. I might guess that you want to invert the function, but it's not invertible, so... clarify what you want. Bobby === > As advertised by the Subject:, I'm new to Mathematica (specifically > 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any > lapses in terminology. I'd also appreciate pointers to specific docs > rather than just an RTFM. I suspect in this case I just need to know > what the appropriate term is for what I'm trying to create. However > I've tried searching the docs for various permutations of multi-rule > or multi-line function, and even googling, to no avail. > > I'm trying to create a notebook that typesets a particular > mathematical function, and then solves it. The function has 2 parts or > rules: it returns k (a constant) for one part of its domain, and 0 > otherwise. This is typically typeset with the function name and the > equals sign on one line, then a large left curly bracket (or brace) > centered on that line, then each rule on a separate line with all the > rule lines to the right of the bracket. For an example in a math > layout, I can almost typeset the function in OpenOffice Math like > > f_x(%chi) = left lbrace stack {k if %chi in [0,1] # 0 otherwise} right > rbrace > > (except that I don't want the closing brace, but that's another > problem). I tried to create this using the palettes, but I didn't see > one that did multiline brackets. What do I need to use? > > Once I've typeset this function, I want to actually solve it. How does > one create a function with multiple rules in Mathematica? > > TIA, Tom Roche > -- DrMajorBob@longhorns.com === Subject: Re: Coolest Mathematica trick you'll see this month guaranteed my dual core Windows behaves as it should .. Jens > I use Linux on my machines and enjoy helping other Archlinux users in > the online forums. A fellow Arch user was having issues with > Mathematica 7. He was plotting a 3D parametric equation and > experiencing a sustained high processor load on this laptop; only > killing the kernel would allow the CPU to idle down. He found that the > laptop's accelerometer kernel driver was eating nearly 30% of the CPU > time.... You'll just have to read the forum to see the rest! > > http://bbs.archlinux.org/viewtopic.php?id=65916 > > Can any Windows or Mac users duplicate this? Or is this a Linux-only > \feature\? Or maybe this is well-known and I'm just late in finding \ out? > > cjpembo > === Subject: Re: Coolest Mathematica trick you'll see this month guaranteed Hi Chris, works as expected without problems: Mathematica version 7, Windows. Daniel > I use Linux on my machines and enjoy helping other Archlinux users in > the online forums. A fellow Arch user was having issues with > Mathematica 7. He was plotting a 3D parametric equation and > experiencing a sustained high processor load on this laptop; only > killing the kernel would allow the CPU to idle down. He found that the > laptop's accelerometer kernel driver was eating nearly 30% of the CPU > time.... You'll just have to read the forum to see the rest! > > http://bbs.archlinux.org/viewtopic.php?id=65916 > > Can any Windows or Mac users duplicate this? Or is this a Linux-only > \feature\? Or maybe this is well-known and I'm just late in finding \ out? > > cjpembo > === Subject: Re: Coolest Mathematica trick you'll see this month guaranteed > I use Linux on my machines and enjoy helping other Archlinux users in > the online forums. A fellow Arch user was having issues with > Mathematica 7. He was plotting a 3D parametric equation and > experiencing a sustained high processor load on this laptop; only > killing the kernel would allow the CPU to idle down. He found that the > laptop's accelerometer kernel driver was eating nearly 30% of the CPU > time.... You'll just have to read the forum to see the rest! > > http://bbs.archlinux.org/viewtopic.php?id=65916 > > Can any Windows or Mac users duplicate this? Or is this a Linux-only > \feature\? Or maybe this is well-known and I'm just late in finding \ ou= t? On Linux, Mathematica will treat devices at /dev/input/js0 through jsN as controllers. As you discovered, apparently this laptop's accelerometer masquerades as a joystick. The high CPU usage is caused by the driver sending many updates to the device file descriptor, which Mathematica watches and does work whenever the values change. This can be disabled by adding the name of the controller (as returned by ControllerInformation[]) to the value list for the undocumented option \DisableControllers\: SetOptions[$FrontEnd, DisableControllers -> Prepend [DisableControllers /. Options[$FrontEnd, DisableControllers], \DEVICE -Rob === Subject: Re: Difference Fit vs. Correlation You gave us GaltonX (which isn't used in your code) and GaltonY, but not GaltonDat. Hence, the following is only a guess as to what you've actually done: lm=LinearModelFit[Transpose@{GaltonX,GaltonY},{1,x},x] FittedModel[33.8866+0.514093 x] lm[\BestFit\] 33.8866+0.514093 x r2=Correlation[GaltonX,GaltonY] 0.501338 Now the question is, why should the two numbers agree? Here's an example from Help: data = {{0, 1}, {1, 0}, {3, 2}, {5, 4}}; lm = LinearModelFit[data, x, x]; lm[\BestFit\] 0.186441 + 0.694915 x The corresponding Correlation is Correlation @@ Transpose@data // N 0.902244 Fit seeks to reproduce Y from X, but Correlation divides covariance by the \ two standard deviations: \Correlation[Subscript[v, 1],Subscript[v, 2]] is equivalent to Covariance[Subscript[v, 1],Subscript[v, 2]]/(StandardDeviation[Subscript[v, 1]]StandardDeviation[Subscript[v, 2]]). \ That's a measure of how much a certain model explains (without the constant term, where your model DOES have a constant term), but it IS NOT a coefficient in the best fit model. Bobby > in the code below, using Correlation I get 0.501338, using Fit I get > 0.514093. > How come? > > Claus > > > In[47]:= GaltonX = {65.04851`, 63.25094`, 64.95532`, 65.7525`, > 61.13723`, 63.02254`, 65.37053`, 64.72398`, 66.06509`, 66.96738`, > 59.008`, 62.93203`, 63.67063`, 64.07386`, 64.68851`, 65.15466`, > 66.37353`, 65.57704`, 67.36765`, 66.75929`, 67.79764`, 69.5348`, > 62.54014`, 63.81016`, 64.4565`, 64.9665`, 64.70662`, 65.73829`, > 65.50141`, 65.55416`, 66.90294`, 66.57388`, 66.53198`, 67.90613`, > 68.29198`, 67.74123`, 68.46917`, 69.38327`, 71.81791`, 62.41615`, > 64.49083`, 64.4876`, 63.92303`, 65.44592`, 65.02977`, 65.67038`, > 68.66078`, 66.54597`, 64.85954`, 69.60692`, 64.8135`, 65.32703`, > 65.83169`, 65.83427`, 65.56135`, 65.8688`, 65.77339`, 67.09116`, > 66.61374`, 67.41075`, 67.27716`, 66.61134`, 68.17412`, 67.80555`, > 68.32529`, 68.07787`, 68.96795`, 68.9255`, 69.60862`, 70.35646`, > 70.00643`, 72.75425`, 62.82147`, 62.86855`, 63.91261`, 64.54118`, > 64.51906`, 66.02688`, 65.81011`, 66.01812`, 65.53742`, 65.73346`, > 66.77424`, 66.67869`, 66.97585`, 66.94021`, 66.84575`, 67.12008`, > 67.74181`, 68.27194`, 67.60691`, 68.44737`, 67.65832`, 68.71193`, > 69.32025`, 68.7403`, 69.13395`, 69.34995`, 68.6297`, 69.58258`, > 70.39517`, 71.19284`, 70.82429`, 71.65367`, 73.28133`, 63.03753`, > 63.66428`, 65.38311`, 64.60205`, 66.40661`, 65.76985`, 65.66729`, > 66.05712`, 66.54635`, 66.5723`, 66.64876`, 67.71899`, 68.48726`, > 67.82769`, 67.55801`, 68.07763`, 69.16715`, 68.693`, 68.61779`, > 68.64797`, 68.61666`, 70.36485`, 70.0099`, 70.13984`, 70.2073`, > 71.28063`, 70.90445`, 72.19036`, 74.96203`, 64.88218`, 65.55174`, > 65.65889`, 65.92826`, 65.94198`, 67.43646`, 67.48444`, 67.61344`, > 68.4518`, 68.49456`, 68.1056`, 69.48308`, 69.07389`, 69.39251`, > 69.44294`, 69.52131`, 70.15463`, 69.86911`, 70.44394`, 70.85393`, > 71.30074`, 72.13978`, 72.19045`, 75.43393`, 64.51788`, 66.36335`, > 65.56855`, 66.78957`, 66.91193`, 68.1714`, 67.50102`, 67.83492`, > 68.95255`, 69.26`, 68.74223`, 69.74288`, 70.29942`, 70.04402`, > 70.23559`, 70.88075`, 71.19091`, 72.37396`, 73.03345`, 74.8083`, > 67.39521`, 67.31523`, 67.77952`, 69.33827`, 68.72404`, 69.98991`, > 69.75383`, 70.65942`, 71.10882`, 72.4811`, 72.4801`, 67.52214`, > 68.23931`, 68.7997`, 69.89568`, 71.48641`, 70.76482`, 71.9137`, > 63.08399`, 68.23241`, 70.05787`, 70.83996`, 72.56944`, 67.93353`, > 67.54033`, 72.79855`, 62.67482`, 68.19196`, 65.07215`, 73.42952`, > 62.94125`, 62.53667`, 69.90248`, 71.07217`, 71.11059`, 69.48402`, > 70.18338`, 65.46124`, 62.04073`, 63.60063`, 65.60613`, 68.02969`, > 61.81571`, 63.78886`, 64.89023`, 65.79072`, 66.42371`, 68.80877`, > 61.76521`, 64.30302`, 63.69064`, 64.99662`, 65.34899`, 64.81278`, > 65.71736`, 66.03148`, 67.04912`, 67.77522`, 69.04964`, 62.1833`, > 62.76393`, 63.88391`, 65.41055`, 64.62347`, 65.64621`, 66.16257`, > 65.99538`, 65.79786`, 67.42936`, 67.11933`, 67.32907`, 67.86233`, > 68.31609`, 67.96359`, 68.68615`, 71.18085`, 62.4296`, 62.88524`, > 64.07313`, 63.88597`, 64.8272`, 65.39653`, 64.77344`, 68.66581`, > 65.19783`, 64.32621`, 66.08278`, 69.01679`, 64.50194`, 66.07654`, > 65.73631`, 66.45485`, 65.63018`, 66.39423`, 67.33687`, 66.83938`, > 66.69739`, 67.34708`, 67.35319`, 67.93575`, 67.76608`, 68.11569`, > 68.2548`, 68.83427`, 69.40758`, 69.32068`, 70.48`, 70.06429`, > 70.63764`, 62.41134`, 63.15274`, 63.51409`, 63.91446`, 64.61683`, > 64.86185`, 65.91332`, 66.1992`, 66.45978`, 65.50286`, 66.87795`, > 67.0791`, 66.83256`, 67.18231`, 66.51763`, 66.95295`, 66.63586`, > 68.18453`, 67.60565`, 68.27918`, 67.97994`, 69.00094`, 69.31139`, > 68.88641`, 68.94824`, 69.42186`, 69.49516`, 70.34647`, 69.92358`, > 70.69078`, 70.56571`, 72.40997`, 72.47685`, 62.72118`, 63.9001`, > 64.50433`, 64.81813`, 65.37582`, 65.82612`, 66.29436`, 65.81042`, > 66.80854`, 67.16724`, 67.30525`, 67.54577`, 67.86855`, 68.35003`, > 67.60818`, 68.48397`, 68.56724`, 69.07405`, 68.56831`, 69.15373`, > 68.60744`, 68.5443`, 69.65536`, 70.41632`, 69.97528`, 70.26613`, > 71.31667`, 71.29178`, 72.59442`, 64.40268`, 64.9127`, 66.34756`, > 66.04291`, 65.69477`, 66.71512`, 66.64971`, 68.33241`, 67.94335`, > 67.96734`, 68.27657`, 68.75008`, 69.05441`, 69.00755`, 69.39488`, > 69.7628`, 69.6464`, 70.45427`, 69.89852`, 70.984`, 71.22015`, > 71.45442`, 71.60966`, 73.20296`, 63.89132`, 65.99384`, 66.0424`, > 67.47658`, 66.68527`, 68.27034`, 67.72898`, 68.28372`, 68.39453`, > 69.12925`, 69.10844`, 69.74196`, 69.9987`, 69.56148`, 69.97779`, > 70.88691`, 70.64687`, 72.26404`, 71.50569`, 73.01402`, 66.20254`, > 67.26312`, 67.8086`, 69.08284`, 69.35107`, 69.59962`, 70.08948`, > 70.18385`, 71.26955`, 72.07717`, 72.33894`, 67.06776`, 67.85929`, > 69.07274`, 69.59893`, 69.73728`, 70.54066`, 72.40962`, 72.78889`, > 68.10144`, 68.6106`, 71.293`, 72.09445`, 74.69236`, 71.16246`, > 68.30804`, 60.41857`, 63.94459`, 63.06849`, 63.98036`, 73.89524`, > 72.03687`, 61.02471`, 65.39914`, 71.96564`, 71.29643`, 65.15837`, > 68.90263`, 64.45192`, 63.99469`, 66.46124`, 67.12556`, 62.27941`, > 63.8488`, 65.43612`, 65.62145`, 66.16956`, 67.62675`, 60.21393`, > 62.99378`, 63.57239`, 65.15088`, 65.13462`, 64.79732`, 66.24856`, > 66.22743`, 66.6056`, 67.99167`, 69.04862`, 62.12902`, 63.16227`, > 64.45497`, 63.75483`, 64.63959`, 64.59106`, 66.06003`, 65.98544`, > 65.66176`, 67.11501`, 67.31302`, 67.16149`, 68.38679`, 67.64175`, > 67.55466`, 68.53614`, 70.02702`, 61.07412`, 62.72387`, 64.28642`, > 64.11073`, 63.68318`, 64.68393`, 64.66753`, 67.95848`, 64.60933`, > 66.07775`, 65.25267`, 69.67201`, 65.33965`, 65.54375`, 66.1112`, > 66.22968`, 66.00879`, 66.03248`, 65.94624`, 67.09734`, 66.98893`, > 67.38837`, 67.4075`, 67.31108`, 68.27151`, 68.33586`, 67.56752`, > 68.23182`, 69.07604`, 68.77033`, 70.49154`, 70.00767`, 69.52007`, > 61.50617`, 62.93875`, 64.10318`, 63.85157`, 65.08731`, 64.62588`, > 65.8912`, 66.24386`, 65.66031`, 66.05344`, 66.30711`, 67.15303`, > 66.90986`, 66.89436`, 66.56566`, 67.23789`, 67.05684`, 67.94515`, > 67.94026`, 67.84234`, 67.91887`, 68.63961`, 68.60477`, 69.04036`, > 69.03336`, 69.12497`, 68.53779`, 70.24335`, 69.84308`, 69.90057`, > 71.48946`, 72.37013`, 71.94413`, 61.01904`, 63.0108`, 64.5793`, > 65.39658`, 64.84995`, 65.54542`, 65.56421`, 66.09747`, 67.40602`, > 66.5839`, 67.41035`, 67.21634`, 68.23175`, 67.88053`, 68.0153`, > 67.69332`, 68.85462`, 68.73264`, 69.0711`, 68.79964`, 68.79876`, > 69.32241`, 69.60923`, 69.76071`, 70.1611`, 70.12109`, 71.10802`, > 71.44164`, 71.75006`, 64.35591`, 65.16253`, 66.09529`, 65.78674`, > 65.53927`, 66.71703`, 67.17284`, 67.16853`, 68.06061`, 67.85988`, > 68.1968`, 69.29537`, 68.84067`, 69.18095`, 68.69659`, 69.45833`, > 70.0483`, 69.6916`, 70.20658`, 70.79086`, 70.87977`, 71.30702`, > 72.3266`, 72.7824`, 64.40052`, 64.89121`, 65.84506`, 67.35461`, > 67.44953`, 67.86439`, 67.92443`, 68.49998`, 67.60602`, 69.37288`, > 69.34931`, 69.48306`, 70.21887`, 70.02161`, 69.83698`, 69.6041`, > 71.49829`, 72.16894`, 72.41045`, 72.52521`, 64.6702`, 66.78417`, > 67.83401`, 68.15907`, 69.19301`, 68.86739`, 70.11126`, 70.12007`, > 71.03691`, 71.43196`, 72.04564`, 72.738`, 68.02564`, 69.04939`, > 68.86356`, 69.63421`, 71.24085`, 71.95679`, 72.89983`, 65.86028`, > 68.48883`, 70.72676`, 72.34582`, 72.59922`, 68.82986`, 73.49987`, > 70.0599`, 67.9291`, 64.66998`, 60.7795`, 74.94058`, 70.64925`, > 60.91526`, 65.28934`, 71.362`, 71.66893`, 62.68868`, 71.39326`, > 66.56302`, 67.18788`, 62.532`, 64.85512`, 66.94161`, 62.3603`, > 63.58145`, 65.44633`, 65.00539`, 66.43717`, 66.6676`, 59.4898`, > 63.00108`, 64.0892`, 64.0753`, 64.52103`, 65.19231`, 66.30604`, > 66.03081`, 66.83096`, 68.19724`, 68.6599`, 61.29369`, 63.26089`, > 63.86162`, 64.13176`, 64.81105`, 64.55987`, 66.19437`, 66.5`, > 66.43436`, 67.30468`, 67.36559`, 67.29162`, 67.69874`, 68.38221`, > 67.76712`, 69.29587`, 69.66477`, 60.03436`, 62.1356`, 63.64047`, > 63.82278`, 64.46555`, 64.73798`, 65.43021`, 65.07381`, 69.29517`, > 67.67996`, 64.94267`, 69.47933`, 65.05963`, 65.01253`, 65.61963`, > 65.94819`, 65.68803`, 65.87689`, 65.91481`, 67.41946`, 66.53833`, > 67.41995`, 67.21977`, 67.33721`, 68.11283`, 68.02017`, 68.02829`, > 68.35139`, 68.80254`, 69.49307`, 70.2297`, 69.71997`, 70.16651`, > 61.07369`, 62.66947`, 64.32254`, 64.27362`, 64.96148`, 64.77222`, > 66.2365`, 66.10686`, 66.42772`, 66.22727`, 65.87574`, 67.03017`, > 67.48545`, 66.7367`, 66.69181`, 67.31766`, 67.1219`, 67.82592`, > 68.4376`, 67.74551`, 68.0934`, 67.71665`, 68.99349`, 69.24616`, > 69.2828`, 69.26254`, 68.75605`, 69.62519`, 69.61942`, 69.94715`, > 70.58916`, 72.34058`, 71.56142`, 72.94457`, 63.33777`, 64.3445`, > 65.14077`, 65.2424`, 65.90397`, 65.98763`, 65.57065`, 65.82733`, > 66.88576`, 66.98594`, 67.41537`, 67.93319`, 67.77812`, 68.44999`, > 68.32281`, 68.35148`, 68.73678`, 68.97673`, 69.31931`, 68.80442`, > 68.90434`, 69.80381`, 69.66712`, 70.38052`, 70.29892`, 71.02634`, > 71.28432`, 72.03259`, 63.26539`, 64.87623`, 65.72722`, 66.13831`, > 66.48902`, 66.06395`, 66.73532`, 67.12329`, 67.57161`, 68.18286`, > 68.33868`, 68.14658`, 69.17022`, 69.17597`, 68.52789`, 68.84874`, > 69.69833`, 69.86528`, 70.48646`, 71.16238`, 70.58946`, 70.54353`, > 72.38576`, 73.18522`, 64.12344`, 64.62855`, 65.74244`, 67.11563`, > 66.81497`, 68.38001`, 68.33835`, 68.25066`, 68.36488`, 68.67873`, > 68.70293`, 69.0466`, 70.17375`, 69.86849`, 70.15821`, 70.24204`, > 71.41811`, 70.66031`, 72.42614`, 73.04341`, 64.6891`, 67.09928`, > 67.79858`, 68.37299`, 69.19364`, 68.5938`, 69.86969`, 70.17952`, > 70.51811`, 71.00743`, 71.83086`, 72.81121`, 67.95451`, 67.81317`, > 69.32812`, 70.45127`, 71.38916`, 72.31022`, 71.8821`, 64.61601`, > 67.75382`, 69.90335`, 70.87039`, 72.71533`, 69.03942`, 72.44463`, > 69.07253`, 70.1758`, 72.37219`, 59.63777`, 73.27737`, 68.12621`, > 63.15234`, 66.00489`, 71.45303`, 68.1456`, 65.25527`, 70.41584`, > 68.38452`, 61.89133`, 64.98391`, 66.21887`, 59.48391`, 62.77645`, > 63.86507`, 64.56486`, 65.60265`, 66.28333`, 70.55256`, 62.14539`, > 64.37906`, 64.35191`, 64.91304`, 65.33085`, 65.17545`, 66.10285`, > 66.05004`, 67.38231`, 67.83999`, 70.27309`, 63.19263`, 63.66834`, > 64.12671`, 64.71388`, 65.14662`, 65.94428`, 65.67785`, 65.95134`, > 67.30819`, 66.69404`, 66.56885`, 66.80951`, 68.24011`, 67.5344`, > 68.4157`, 69.09588`, 70.81036`, 61.68183`, 63.04493`, 64.34945`, > 63.89336`, 65.48176`, 64.726`, 64.65128`, 67.47271`, 66.76701`, > 64.98147`, 69.38684`, 63.7123`, 64.63358`, 66.00037`, 65.96621`, > 66.49751`, 66.27177`, 65.67892`, 66.86814`, 66.73495`, 66.53357`, > 67.05051`, 67.04958`, 67.55908`, 67.58076`, 67.51942`, 68.12592`, > 68.57465`, 68.52484`, 69.20286`, 69.7551`, 69.91868`, 70.50329`, > 62.83528`, 63.24504`, 64.44602`, 64.31819`, 64.73521`, 64.72352`, > 65.97741`, 65.63739`, 65.83449`, 65.87064`, 66.61001`, 66.75821`, > 66.77012`, 67.21373`, 67.09047`, 66.93359`, 68.03852`, 67.98476`, > 68.25046`, 68.26078`, 68.21235`, 68.54029`, 68.50469`, 69.13248`, > 69.21981`, 69.34385`, 69.41153`, 70.25056`, 69.68641`, 70.51091`, > 71.29598`, 72.20218`, 72.33929`, 62.91628`, 63.93525`, 64.59851`, > 65.47401`, 65.864`, 66.30684`, 65.77587`, 66.48386`, 67.31983`, > 67.39901`, 67.05939`, 68.45161`, 67.7061`, 68.08389`, 67.58923`, > 67.80388`, 69.25919`, 69.05302`, 68.70921`, 69.02788`, 68.94943`, > 68.81536`, 69.91801`, 70.45072`, 69.96349`, 69.75787`, 71.38281`, > 71.08122`, 72.74936`, 65.26855`, 66.01549`, 65.5142`, 65.62374`, > 65.92199`, 67.11129`, 66.89727`, 67.94195`, 67.7274`, 67.54999`, > 67.96013`, 68.83038`, 69.43917`, 68.55957`, 69.10638`, 70.4814`, > 69.92992`, 70.04238`, 69.56779`, 71.01077`, 70.62603`, 71.46383`, > 71.62112`, 73.87758`, 65.00573`, 66.30354`, 65.86743`, 66.86667`, > 67.15958`, 68.06904`, 67.57382`, 67.63354`, 69.41356`, 68.87192`, > 69.07779`, 69.81177`, 70.01463`, 69.56649`, 70.254`, 70.68296`, > 70.87874`, 72.45099`, 73.04359`, 74.40915`, 67.40139`, 66.53122`, > 68.04593`, 68.82772`, 69.33069`, 70.34676`, 70.173`, 70.80883`, > 70.7029`, 72.35959`, 72.3661`, 67.17534`, 67.84045`, 68.9053`, > 70.3752`, 71.18523`, 71.41254`, 71.70673`, 72.60072`, 67.57652`, > 68.55814`, 70.95019`, 71.99783`, 75.17469`, 73.07157`, 69.92407`, > 65.54323`, 72.56261`, 72.15051`, 63.22006`, 73.2645`, 65.81296`, > 67.70657`, 66.99681`, 71.33181`, 71.78314`, 70.73837`, 70.30609`}; > > In[59]:= GaltonY = {59.77827`, 63.21404`, 63.34242`, 62.79238`, > 64.28113`, 64.24221`, 64.08231`, 63.99574`, 64.61338`, 63.97944`, > 65.24451`, 65.35102`, 65.67992`, 65.43664`, 65.29391`, 64.79017`, > 65.01881`, 65.5464`, 65.08145`, 65.49008`, 65.1352`, 65.51262`, > 66.58436`, 66.37842`, 66.14782`, 65.97259`, 65.95887`, 66.45202`, > 65.74797`, 65.97164`, 65.90548`, 65.90773`, 66.47103`, 65.75023`, > 66.34666`, 66.08577`, 66.28037`, 66.34354`, 66.41711`, 67.22558`, > 67.46394`, 66.99362`, 66.76647`, 67.0342`, 66.84316`, 69.2989`, > 69.09114`, 61.66358`, 65.7288`, 68.98012`, 67.37397`, 67.17459`, > 67.06712`, 67.29446`, 67.62665`, 67.47923`, 66.92162`, 67.58324`, > 67.21191`, 66.81629`, 67.24268`, 67.51036`, 67.57026`, 67.17258`, > 67.54129`, 67.37113`, 67.59714`, 67.25104`, 66.82533`, 66.72679`, > 66.92996`, 67.64847`, 68.04291`, 68.4885`, 68.04777`, 68.34573`, > 68.33829`, 68.3138`, 68.18333`, 68.51056`, 68.12014`, 68.31563`, > 68.04774`, 68.61273`, 67.9425`, 68.08381`, 68.36754`, 67.85181`, > 68.19806`, 68.01897`, 68.23431`, 67.89742`, 68.62409`, 67.97912`, > 68.2668`, 67.94192`, 68.62072`, 68.23857`, 68.58554`, 68.06568`, > 68.38188`, 67.75943`, 68.59991`, 67.91483`, 67.83861`, 68.77562`, > 69.60782`, 69.69143`, 69.41491`, 69.68931`, 69.20775`, 69.45627`, > 69.59614`, 69.27994`, 69.52338`, 68.74406`, 69.30987`, 69.22571`, > 69.24073`, 69.4912`, 69.11921`, 68.93751`, 69.45774`, 69.27599`, > 69.22869`, 68.70547`, 69.34638`, 68.87137`, 69.30262`, 69.1579`, > 69.62727`, 69.11014`, 69.09596`, 69.03281`, 69.85677`, 70.06274`, > 69.89765`, 70.26185`, 70.52663`, 70.52744`, 69.7865`, 70.36684`, > 69.97604`, 69.83308`, 70.69951`, 70.16871`, 70.11632`, 69.95433`, > 70.31279`, 69.80903`, 69.96792`, 69.93939`, 69.73486`, 70.08397`, > 70.01015`, 70.65025`, 70.01253`, 70.09077`, 71.34319`, 70.81542`, > 71.44929`, 71.18676`, 71.66276`, 71.39516`, 70.73612`, 71.2608`, > 71.04721`, 71.2592`, 70.89486`, 71.31732`, 71.55712`, 71.17701`, > 71.03412`, 71.37275`, 71.64741`, 71.1205`, 70.91756`, 71.66455`, > 72.39198`, 71.87928`, 72.34482`, 72.17265`, 72.52078`, 71.98836`, > 72.34482`, 72.45347`, 72.26945`, 71.96844`, 72.18169`, 72.7864`, > 73.0414`, 72.87858`, 73.17304`, 73.63274`, 72.88245`, 73.18148`, > 74.3209`, 74.40727`, 73.76791`, 73.92119`, 73.75503`, 75.56214`, > 75.70222`, 77.21338`, 61.28882`, 74.28343`, 70.93102`, 75.34802`, > 61.78758`, 64.00009`, 62.4658`, 73.70465`, 66.3495`, 62.20543`, > 65.421`, 63.9922`, 62.78458`, 63.52486`, 63.49966`, 62.89658`, > 63.72784`, 63.73231`, 64.39579`, 63.70072`, 64.44796`, 64.2795`, > 65.18412`, 65.10118`, 65.56277`, 64.94454`, 65.14227`, 65.16843`, > 65.58149`, 65.63474`, 64.87191`, 65.4176`, 64.7231`, 65.84559`, > 65.77333`, 66.67371`, 66.54726`, 66.43228`, 66.3326`, 66.24935`, > 66.39759`, 66.69366`, 66.22114`, 66.43499`, 66.65758`, 65.76873`, > 66.20784`, 66.30166`, 65.81894`, 66.34562`, 66.88369`, 66.8162`, > 67.36245`, 67.68308`, 67.19885`, 67.26903`, 67.45131`, 68.95907`, > 62.013`, 64.10658`, 66.00879`, 65.77796`, 66.94446`, 66.81229`, > 67.01431`, 67.43705`, 66.8442`, 67.25391`, 67.52273`, 67.17782`, > 67.6068`, 66.8991`, 66.74675`, 67.16928`, 67.23833`, 66.75589`, > 66.79828`, 67.488`, 67.1104`, 67.06455`, 66.93899`, 67.54723`, > 66.85662`, 67.70971`, 67.88296`, 68.66534`, 68.58164`, 68.44493`, > 68.41199`, 68.44665`, 68.38258`, 67.92987`, 68.3033`, 67.97479`, > 68.18304`, 68.57984`, 68.56974`, 67.81854`, 67.8796`, 68.22794`, > 68.01258`, 67.85023`, 67.80077`, 68.59968`, 68.08671`, 67.87656`, > 68.47849`, 68.60006`, 68.07838`, 68.08199`, 67.73211`, 68.4132`, > 68.59541`, 68.28458`, 68.06489`, 68.41445`, 69.36998`, 69.00435`, > 69.37297`, 68.89496`, 69.37382`, 69.34415`, 68.96686`, 69.59887`, > 69.24597`, 69.68301`, 68.90541`, 69.07283`, 69.03297`, 69.18202`, > 69.64233`, 68.82818`, 69.24165`, 69.10265`, 68.98512`, 69.31551`, > 69.20435`, 68.93765`, 69.36661`, 68.71181`, 68.75662`, 69.35439`, > 69.74222`, 69.82326`, 69.90223`, 70.2992`, 69.83745`, 69.94847`, > 70.27479`, 70.67752`, 70.38903`, 70.37578`, 70.60668`, 70.16921`, > 69.85223`, 70.23353`, 70.28373`, 70.33881`, 69.81443`, 70.54739`, > 69.96746`, 69.73702`, 69.8604`, 70.87111`, 71.36657`, 71.1878`, > 70.75001`, 70.72998`, 71.32092`, 70.88794`, 70.9085`, 70.87662`, > 71.19803`, 71.31925`, 71.22916`, 71.35939`, 71.60205`, 70.97309`, > 71.1886`, 71.40319`, 71.39524`, 70.88752`, 71.27449`, 72.10289`, > 72.03197`, 71.9969`, 71.72577`, 71.92914`, 72.20518`, 72.29401`, > 72.5854`, 72.04673`, 71.80541`, 71.80464`, 73.06559`, 73.44548`, > 73.19223`, 73.37471`, 73.22554`, 72.88357`, 72.77826`, 73.26989`, > 73.96165`, 74.64342`, 73.92565`, 74.58767`, 74.31029`, 75.10003`, > 77.15504`, 60.78204`, 62.36303`, 66.40186`, 58.50708`, 70.00052`, > 70.99433`, 64.96417`, 70.47639`, 69.23383`, 64.90184`, 68.7749`, > 69.85805`, 62.52373`, 63.28805`, 63.52861`, 62.87456`, 63.91754`, > 64.32325`, 64.22405`, 64.59643`, 64.28548`, 63.78835`, 65.66404`, > 64.80838`, 65.63528`, 64.74897`, 64.79081`, 65.10988`, 65.55215`, > 65.30083`, 65.1426`, 65.09433`, 64.81397`, 65.95058`, 66.37511`, > 66.38624`, 66.31904`, 65.80919`, 66.09556`, 66.49077`, 66.32632`, > 66.59779`, 66.00909`, 66.45585`, 66.00818`, 66.46605`, 66.37783`, > 66.34685`, 66.31558`, 66.62303`, 66.79229`, 67.5336`, 67.15587`, > 66.78051`, 67.25544`, 66.79006`, 66.88298`, 68.1121`, 63.61572`, > 63.17978`, 65.67211`, 67.23403`, 67.4089`, 67.57913`, 67.20643`, > 67.10018`, 66.80557`, 67.09308`, 66.91372`, 66.77528`, 66.97572`, > 67.66639`, 67.62089`, 67.66841`, 67.32572`, 67.04153`, 66.96445`, > 67.07223`, 67.169`, 67.48077`, 67.67057`, 66.86465`, 67.04437`, > 67.72523`, 68.52969`, 67.8741`, 67.84693`, 68.26632`, 68.18364`, > 68.55723`, 67.77137`, 67.92976`, 67.72522`, 67.98916`, 68.0679`, > 67.772`, 68.11035`, 68.16623`, 68.61054`, 68.2893`, 68.38263`, > 68.6212`, 68.27802`, 67.93914`, 67.7105`, 68.351`, 68.14712`, > 67.97421`, 68.23682`, 68.05699`, 68.49856`, 68.58894`, 67.74098`, > 68.69765`, 68.63531`, 68.37844`, 69.11352`, 69.35385`, 69.5135`, > 69.11`, 69.64324`, 69.40655`, 69.18575`, 68.80709`, 69.11679`, > 69.02706`, 69.05703`, 69.14581`, 68.7308`, 68.9798`, 68.95303`, > 69.1639`, 68.81649`, 68.73746`, 69.00102`, 69.28222`, 69.37676`, > 68.90879`, 69.32318`, 69.63872`, 69.43581`, 68.97885`, 69.54252`, > 68.73497`, 69.20127`, 70.36167`, 70.10118`, 70.39507`, 70.03877`, > 69.76556`, 70.39131`, 70.0372`, 70.25908`, 69.87081`, 70.69845`, > 70.25756`, 69.7177`, 70.31993`, 69.95735`, 69.72691`, 70.22698`, > 70.02038`, 70.32035`, 70.39947`, 69.78074`, 69.7598`, 70.53827`, > 70.03449`, 70.59135`, 71.13378`, 71.15371`, 71.03018`, 70.93936`, > 70.78603`, 71.50695`, 71.57023`, 70.83563`, 70.96118`, 71.55428`, > 71.08274`, 71.49587`, 71.36997`, 71.49891`, 71.01177`, 71.62784`, > 71.36701`, 71.23426`, 70.90129`, 71.53087`, 72.441`, 72.5999`, > 71.79167`, 72.00806`, 72.01746`, 72.44981`, 71.92864`, 72.0908`, > 72.57398`, 72.53335`, 71.78483`, 72.57594`, 73.06795`, 73.18852`, > 73.39371`, 73.3754`, 73.67679`, 72.84789`, 72.99608`, 74.67822`, > 73.8507`, 74.35692`, 73.99906`, 73.92525`, 75.67784`, 76.10484`, > 78.2476`, 61.89619`, 69.86215`, 62.26801`, 71.40839`, 71.60925`, > 65.51351`, 71.86574`, 71.16645`, 64.53321`, 65.25053`, 69.62871`, > 65.10223`, 61.03526`, 63.12132`, 63.5968`, 63.47848`, 63.83162`, > 64.18388`, 64.66888`, 64.06363`, 64.38072`, 64.60295`, 64.81735`, > 65.22864`, 65.62354`, 65.62755`, 64.8584`, 65.6482`, 65.6904`, > 65.58218`, 65.08945`, 64.87234`, 65.68794`, 66.54461`, 66.23255`, > 65.91034`, 66.29882`, 66.33603`, 66.19024`, 66.12728`, 66.1938`, > 65.82389`, 66.61389`, 66.45299`, 66.25633`, 66.53703`, 66.28457`, > 65.90354`, 66.61969`, 66.59349`, 67.30641`, 67.41523`, 67.51658`, > 66.94071`, 67.11246`, 66.99107`, 66.94124`, 68.06898`, 67.47908`, > 63.00731`, 67.40208`, 68.75691`, 66.90827`, 67.28305`, 67.15978`, > 67.12405`, 67.07313`, 67.17665`, 66.74724`, 66.81865`, 67.43735`, > 67.37322`, 66.96049`, 67.40154`, 66.91834`, 66.93007`, 66.78425`, > 66.7842`, 67.15158`, 67.45025`, 67.68985`, 67.13767`, 67.60589`, > 67.96334`, 68.65674`, 68.42972`, 68.01111`, 68.61891`, 68.50647`, > 67.77439`, 68.09837`, 68.19228`, 68.54918`, 68.59413`, 68.65282`, > 68.40294`, 68.54259`, 68.59444`, 67.87885`, 68.0454`, 67.96346`, > 68.55092`, 68.07785`, 67.93252`, 68.5916`, 67.90891`, 68.63842`, > 68.6514`, 68.40634`, 68.19563`, 68.3391`, 68.13175`, 67.79551`, > 68.24471`, 67.96366`, 68.02669`, 68.07695`, 69.23339`, 69.22874`, > 68.9062`, 69.33247`, 69.53206`, 69.02418`, 69.26288`, 69.55433`, > 69.3664`, 68.96569`, 69.33038`, 69.10425`, 69.29199`, 69.26009`, > 68.71424`, 69.48488`, 69.48141`, 68.88311`, 68.83524`, 69.42378`, > 68.82387`, 69.06951`, 69.18528`, 69.26989`, 68.83727`, 69.11594`, > 69.39569`, 68.70258`, 70.39288`, 70.49606`, 70.11817`, 69.75304`, > 70.25238`, 70.28837`, 69.71807`, 70.13835`, 70.41752`, 69.91638`, > 69.7803`, 69.90789`, 70.29221`, 70.20136`, 70.42766`, 70.40239`, > 70.65713`, 69.7276`, 70.45174`, 70.52536`, 70.45682`, 70.52011`, > 70.25621`, 70.32714`, 71.39933`, 71.03487`, 71.61276`, 70.90129`, > 71.36831`, 71.46158`, 71.22939`, 71.59368`, 71.6476`, 71.33885`, > 71.13133`, 71.52388`, 70.95837`, 71.48199`, 70.85433`, 71.41922`, > 71.30872`, 71.22321`, 71.4506`, 70.76122`, 72.65576`, 71.96434`, > 72.3071`, 72.2446`, 72.38029`, 72.04211`, 71.77644`, 72.54877`, > 72.57381`, 71.90584`, 72.62022`, 72.4218`, 73.13823`, 73.60773`, > 73.2649`, 73.0769`, 73.69792`, 73.60551`, 72.87015`, 73.90142`, > 74.32431`, 73.87776`, 74.20972`, 74.47833`, 75.07304`, 76.3516`, > 78.36479`, 61.22021`, 72.63356`, 64.94291`, 73.02984`, 71.81569`, > 65.29123`, 60.90911`, 72.131`, 70.98853`, 61.7019`, 67.51436`, > 64.37789`, 63.2825`, 63.47892`, 63.66235`, 63.94637`, 63.93831`, > 63.94722`, 64.08187`, 64.68702`, 64.38337`, 63.91132`, 64.84282`, > 65.33216`, 65.2375`, 65.47348`, 65.16309`, 65.35727`, 65.59545`, > 64.70258`, 64.76966`, 65.55892`, 65.42338`, 66.54624`, 65.70133`, > 66.12315`, 66.2678`, 66.55539`, 66.42398`, 66.50633`, 66.27712`, > 66.42142`, 66.25827`, 66.1285`, 66.53558`, 66.32575`, 66.11991`, > 65.87925`, 65.70978`, 66.10198`, 67.57237`, 67.4361`, 67.00761`, > 67.21048`, 67.1921`, 67.39528`, 67.44979`, 68.18883`, 62.74094`, > 66.34954`, 65.69966`, 68.36264`, 67.52548`, 67.24632`, 67.21519`, > 67.45383`, 66.93472`, 67.6832`, 66.97218`, 66.73049`, 66.75153`, > 67.4346`, 66.92896`, 67.49282`, 66.93944`, 67.03135`, 66.91542`, > 66.97758`, 67.14932`, 67.53093`, 67.52202`, 67.27928`, 67.56893`, > 67.75773`, 68.10565`, 68.49664`, 68.5851`, 67.85579`, 68.60796`, > 68.19156`, 68.25828`, 68.15401`, 68.18623`, 68.16064`, 68.6097`, > 68.34391`, 68.65678`, 68.51914`, 67.72093`, 67.96986`, 67.75073`, > 68.09745`, 68.64602`, 68.2318`, 68.18244`, 68.15011`, 68.13611`, > 68.10048`, 68.53037`, 68.37728`, 68.17652`, 67.7452`, 67.93037`, > 68.25872`, 68.33639`, 68.27405`, 69.5816`, 68.70027`, 68.93075`, > 68.78663`, 69.0649`, 68.99285`, 68.99516`, 68.73929`, 69.47357`, > 69.08392`, 69.07281`, 69.62286`, 69.35683`, 69.16149`, 68.81413`, > 68.9529`, 69.47561`, 69.5506`, 69.38889`, 69.57241`, 69.37092`, > 68.92229`, 68.71081`, 69.2671`, 68.74473`, 68.81509`, 69.47472`, > 69.69307`, 69.65334`, 70.46902`, 70.00607`, 70.61711`, 70.51318`, > 69.97204`, 69.92313`, 70.46938`, 69.91923`, 69.71908`, 70.61155`, > 70.20868`, 70.27586`, 70.18348`, 70.5115`, 70.50015`, 70.24017`, > 70.001`, 70.21726`, 70.20554`, 69.97788`, 70.36632`, 70.38931`, > 70.18593`, 70.23168`, 70.74197`, 71.47899`, 71.41695`, 71.20207`, > 70.87987`, 71.26557`, 71.41653`, 71.24074`, 71.15528`, 71.20588`, > 70.98515`, 71.35642`, 71.21331`, 71.59639`, 71.25854`, 71.53325`, > 70.92787`, 71.54787`, 71.07293`, 70.86163`, 72.67319`, 71.77245`, > 72.64278`, 72.48159`, 71.9078`, 72.18324`, 72.55104`, 72.33861`, > 72.07098`, 72.30647`, 72.05185`, 72.75204`, 72.79178`, 73.50606`, > 73.68578`, 72.79593`, 73.41049`, 73.02077`, 73.20758`, 74.49237`, > 73.81263`, 73.81376`, 73.82642`, 73.81739`, 75.57544`, 77.23474`, > 60.05859`, 76.81927`, 66.72684`, 58.79456`, 67.89277`, 61.04946`, > 59.81693`, 70.75232`, 68.26774`, 69.30589`, 69.30199`, 67.015`}; > > In[60]:= lm = LinearModelFit[GaltonDat, {1, x}, x] > > Out[60]= FittedModel[\\!\\(\\* > PanelBox[ > TagBox[ > RowBox[{\33.88660435407788`\, \ \, \+\, > RowBox[{\0.5140930386233082`\, \ \, \x\}]}], > Short], > FrameMargins->5]\\)] > > In[62]:= lm[\BestFit\] > > Out[62]= 33.8866 + 0.514093 x > > In[63]:= r2 = Correlation[GaltonX, GaltonY] > > Out[63]= 0.501338 > -- DrMajorBob@longhorns.com === Subject: Re: Difference Fit vs. Correlation Hi Claus, you are confusing two different things. The correlation coefficient is not the slope of the regression line. The correlation tells you how much the points are \scattered\ around the \ line. hope this helps, Daniel > in the code below, using Correlation I get 0.501338, using Fit I get > 0.514093. > How come? > > Claus > > > In[47]:= GaltonX = {65.04851`, 63.25094`, 64.95532`, 65.7525`, > 61.13723`, 63.02254`, 65.37053`, 64.72398`, 66.06509`, 66.96738`, > 59.008`, 62.93203`, 63.67063`, 64.07386`, 64.68851`, 65.15466`, > 66.37353`, 65.57704`, 67.36765`, 66.75929`, 67.79764`, 69.5348`, > 62.54014`, 63.81016`, 64.4565`, 64.9665`, 64.70662`, 65.73829`, > 65.50141`, 65.55416`, 66.90294`, 66.57388`, 66.53198`, 67.90613`, > 68.29198`, 67.74123`, 68.46917`, 69.38327`, 71.81791`, 62.41615`, > 64.49083`, 64.4876`, 63.92303`, 65.44592`, 65.02977`, 65.67038`, > 68.66078`, 66.54597`, 64.85954`, 69.60692`, 64.8135`, 65.32703`, > 65.83169`, 65.83427`, 65.56135`, 65.8688`, 65.77339`, 67.09116`, > 66.61374`, 67.41075`, 67.27716`, 66.61134`, 68.17412`, 67.80555`, > 68.32529`, 68.07787`, 68.96795`, 68.9255`, 69.60862`, 70.35646`, > 70.00643`, 72.75425`, 62.82147`, 62.86855`, 63.91261`, 64.54118`, > 64.51906`, 66.02688`, 65.81011`, 66.01812`, 65.53742`, 65.73346`, > 66.77424`, 66.67869`, 66.97585`, 66.94021`, 66.84575`, 67.12008`, > 67.74181`, 68.27194`, 67.60691`, 68.44737`, 67.65832`, 68.71193`, > 69.32025`, 68.7403`, 69.13395`, 69.34995`, 68.6297`, 69.58258`, > 70.39517`, 71.19284`, 70.82429`, 71.65367`, 73.28133`, 63.03753`, > 63.66428`, 65.38311`, 64.60205`, 66.40661`, 65.76985`, 65.66729`, > 66.05712`, 66.54635`, 66.5723`, 66.64876`, 67.71899`, 68.48726`, > 67.82769`, 67.55801`, 68.07763`, 69.16715`, 68.693`, 68.61779`, > 68.64797`, 68.61666`, 70.36485`, 70.0099`, 70.13984`, 70.2073`, > 71.28063`, 70.90445`, 72.19036`, 74.96203`, 64.88218`, 65.55174`, > 65.65889`, 65.92826`, 65.94198`, 67.43646`, 67.48444`, 67.61344`, > 68.4518`, 68.49456`, 68.1056`, 69.48308`, 69.07389`, 69.39251`, > 69.44294`, 69.52131`, 70.15463`, 69.86911`, 70.44394`, 70.85393`, > 71.30074`, 72.13978`, 72.19045`, 75.43393`, 64.51788`, 66.36335`, > 65.56855`, 66.78957`, 66.91193`, 68.1714`, 67.50102`, 67.83492`, > 68.95255`, 69.26`, 68.74223`, 69.74288`, 70.29942`, 70.04402`, > 70.23559`, 70.88075`, 71.19091`, 72.37396`, 73.03345`, 74.8083`, > 67.39521`, 67.31523`, 67.77952`, 69.33827`, 68.72404`, 69.98991`, > 69.75383`, 70.65942`, 71.10882`, 72.4811`, 72.4801`, 67.52214`, > 68.23931`, 68.7997`, 69.89568`, 71.48641`, 70.76482`, 71.9137`, > 63.08399`, 68.23241`, 70.05787`, 70.83996`, 72.56944`, 67.93353`, > 67.54033`, 72.79855`, 62.67482`, 68.19196`, 65.07215`, 73.42952`, > 62.94125`, 62.53667`, 69.90248`, 71.07217`, 71.11059`, 69.48402`, > 70.18338`, 65.46124`, 62.04073`, 63.60063`, 65.60613`, 68.02969`, > 61.81571`, 63.78886`, 64.89023`, 65.79072`, 66.42371`, 68.80877`, > 61.76521`, 64.30302`, 63.69064`, 64.99662`, 65.34899`, 64.81278`, > 65.71736`, 66.03148`, 67.04912`, 67.77522`, 69.04964`, 62.1833`, > 62.76393`, 63.88391`, 65.41055`, 64.62347`, 65.64621`, 66.16257`, > 65.99538`, 65.79786`, 67.42936`, 67.11933`, 67.32907`, 67.86233`, > 68.31609`, 67.96359`, 68.68615`, 71.18085`, 62.4296`, 62.88524`, > 64.07313`, 63.88597`, 64.8272`, 65.39653`, 64.77344`, 68.66581`, > 65.19783`, 64.32621`, 66.08278`, 69.01679`, 64.50194`, 66.07654`, > 65.73631`, 66.45485`, 65.63018`, 66.39423`, 67.33687`, 66.83938`, > 66.69739`, 67.34708`, 67.35319`, 67.93575`, 67.76608`, 68.11569`, > 68.2548`, 68.83427`, 69.40758`, 69.32068`, 70.48`, 70.06429`, > 70.63764`, 62.41134`, 63.15274`, 63.51409`, 63.91446`, 64.61683`, > 64.86185`, 65.91332`, 66.1992`, 66.45978`, 65.50286`, 66.87795`, > 67.0791`, 66.83256`, 67.18231`, 66.51763`, 66.95295`, 66.63586`, > 68.18453`, 67.60565`, 68.27918`, 67.97994`, 69.00094`, 69.31139`, > 68.88641`, 68.94824`, 69.42186`, 69.49516`, 70.34647`, 69.92358`, > 70.69078`, 70.56571`, 72.40997`, 72.47685`, 62.72118`, 63.9001`, > 64.50433`, 64.81813`, 65.37582`, 65.82612`, 66.29436`, 65.81042`, > 66.80854`, 67.16724`, 67.30525`, 67.54577`, 67.86855`, 68.35003`, > 67.60818`, 68.48397`, 68.56724`, 69.07405`, 68.56831`, 69.15373`, > 68.60744`, 68.5443`, 69.65536`, 70.41632`, 69.97528`, 70.26613`, > 71.31667`, 71.29178`, 72.59442`, 64.40268`, 64.9127`, 66.34756`, > 66.04291`, 65.69477`, 66.71512`, 66.64971`, 68.33241`, 67.94335`, > 67.96734`, 68.27657`, 68.75008`, 69.05441`, 69.00755`, 69.39488`, > 69.7628`, 69.6464`, 70.45427`, 69.89852`, 70.984`, 71.22015`, > 71.45442`, 71.60966`, 73.20296`, 63.89132`, 65.99384`, 66.0424`, > 67.47658`, 66.68527`, 68.27034`, 67.72898`, 68.28372`, 68.39453`, > 69.12925`, 69.10844`, 69.74196`, 69.9987`, 69.56148`, 69.97779`, > 70.88691`, 70.64687`, 72.26404`, 71.50569`, 73.01402`, 66.20254`, > 67.26312`, 67.8086`, 69.08284`, 69.35107`, 69.59962`, 70.08948`, > 70.18385`, 71.26955`, 72.07717`, 72.33894`, 67.06776`, 67.85929`, > 69.07274`, 69.59893`, 69.73728`, 70.54066`, 72.40962`, 72.78889`, > 68.10144`, 68.6106`, 71.293`, 72.09445`, 74.69236`, 71.16246`, > 68.30804`, 60.41857`, 63.94459`, 63.06849`, 63.98036`, 73.89524`, > 72.03687`, 61.02471`, 65.39914`, 71.96564`, 71.29643`, 65.15837`, > 68.90263`, 64.45192`, 63.99469`, 66.46124`, 67.12556`, 62.27941`, > 63.8488`, 65.43612`, 65.62145`, 66.16956`, 67.62675`, 60.21393`, > 62.99378`, 63.57239`, 65.15088`, 65.13462`, 64.79732`, 66.24856`, > 66.22743`, 66.6056`, 67.99167`, 69.04862`, 62.12902`, 63.16227`, > 64.45497`, 63.75483`, 64.63959`, 64.59106`, 66.06003`, 65.98544`, > 65.66176`, 67.11501`, 67.31302`, 67.16149`, 68.38679`, 67.64175`, > 67.55466`, 68.53614`, 70.02702`, 61.07412`, 62.72387`, 64.28642`, > 64.11073`, 63.68318`, 64.68393`, 64.66753`, 67.95848`, 64.60933`, > 66.07775`, 65.25267`, 69.67201`, 65.33965`, 65.54375`, 66.1112`, > 66.22968`, 66.00879`, 66.03248`, 65.94624`, 67.09734`, 66.98893`, > 67.38837`, 67.4075`, 67.31108`, 68.27151`, 68.33586`, 67.56752`, > 68.23182`, 69.07604`, 68.77033`, 70.49154`, 70.00767`, 69.52007`, > 61.50617`, 62.93875`, 64.10318`, 63.85157`, 65.08731`, 64.62588`, > 65.8912`, 66.24386`, 65.66031`, 66.05344`, 66.30711`, 67.15303`, > 66.90986`, 66.89436`, 66.56566`, 67.23789`, 67.05684`, 67.94515`, > 67.94026`, 67.84234`, 67.91887`, 68.63961`, 68.60477`, 69.04036`, > 69.03336`, 69.12497`, 68.53779`, 70.24335`, 69.84308`, 69.90057`, > 71.48946`, 72.37013`, 71.94413`, 61.01904`, 63.0108`, 64.5793`, > 65.39658`, 64.84995`, 65.54542`, 65.56421`, 66.09747`, 67.40602`, > 66.5839`, 67.41035`, 67.21634`, 68.23175`, 67.88053`, 68.0153`, > 67.69332`, 68.85462`, 68.73264`, 69.0711`, 68.79964`, 68.79876`, > 69.32241`, 69.60923`, 69.76071`, 70.1611`, 70.12109`, 71.10802`, > 71.44164`, 71.75006`, 64.35591`, 65.16253`, 66.09529`, 65.78674`, > 65.53927`, 66.71703`, 67.17284`, 67.16853`, 68.06061`, 67.85988`, > 68.1968`, 69.29537`, 68.84067`, 69.18095`, 68.69659`, 69.45833`, > 70.0483`, 69.6916`, 70.20658`, 70.79086`, 70.87977`, 71.30702`, > 72.3266`, 72.7824`, 64.40052`, 64.89121`, 65.84506`, 67.35461`, > 67.44953`, 67.86439`, 67.92443`, 68.49998`, 67.60602`, 69.37288`, > 69.34931`, 69.48306`, 70.21887`, 70.02161`, 69.83698`, 69.6041`, > 71.49829`, 72.16894`, 72.41045`, 72.52521`, 64.6702`, 66.78417`, > 67.83401`, 68.15907`, 69.19301`, 68.86739`, 70.11126`, 70.12007`, > 71.03691`, 71.43196`, 72.04564`, 72.738`, 68.02564`, 69.04939`, > 68.86356`, 69.63421`, 71.24085`, 71.95679`, 72.89983`, 65.86028`, > 68.48883`, 70.72676`, 72.34582`, 72.59922`, 68.82986`, 73.49987`, > 70.0599`, 67.9291`, 64.66998`, 60.7795`, 74.94058`, 70.64925`, > 60.91526`, 65.28934`, 71.362`, 71.66893`, 62.68868`, 71.39326`, > 66.56302`, 67.18788`, 62.532`, 64.85512`, 66.94161`, 62.3603`, > 63.58145`, 65.44633`, 65.00539`, 66.43717`, 66.6676`, 59.4898`, > 63.00108`, 64.0892`, 64.0753`, 64.52103`, 65.19231`, 66.30604`, > 66.03081`, 66.83096`, 68.19724`, 68.6599`, 61.29369`, 63.26089`, > 63.86162`, 64.13176`, 64.81105`, 64.55987`, 66.19437`, 66.5`, > 66.43436`, 67.30468`, 67.36559`, 67.29162`, 67.69874`, 68.38221`, > 67.76712`, 69.29587`, 69.66477`, 60.03436`, 62.1356`, 63.64047`, > 63.82278`, 64.46555`, 64.73798`, 65.43021`, 65.07381`, 69.29517`, > 67.67996`, 64.94267`, 69.47933`, 65.05963`, 65.01253`, 65.61963`, > 65.94819`, 65.68803`, 65.87689`, 65.91481`, 67.41946`, 66.53833`, > 67.41995`, 67.21977`, 67.33721`, 68.11283`, 68.02017`, 68.02829`, > 68.35139`, 68.80254`, 69.49307`, 70.2297`, 69.71997`, 70.16651`, > 61.07369`, 62.66947`, 64.32254`, 64.27362`, 64.96148`, 64.77222`, > 66.2365`, 66.10686`, 66.42772`, 66.22727`, 65.87574`, 67.03017`, > 67.48545`, 66.7367`, 66.69181`, 67.31766`, 67.1219`, 67.82592`, > 68.4376`, 67.74551`, 68.0934`, 67.71665`, 68.99349`, 69.24616`, > 69.2828`, 69.26254`, 68.75605`, 69.62519`, 69.61942`, 69.94715`, > 70.58916`, 72.34058`, 71.56142`, 72.94457`, 63.33777`, 64.3445`, > 65.14077`, 65.2424`, 65.90397`, 65.98763`, 65.57065`, 65.82733`, > 66.88576`, 66.98594`, 67.41537`, 67.93319`, 67.77812`, 68.44999`, > 68.32281`, 68.35148`, 68.73678`, 68.97673`, 69.31931`, 68.80442`, > 68.90434`, 69.80381`, 69.66712`, 70.38052`, 70.29892`, 71.02634`, > 71.28432`, 72.03259`, 63.26539`, 64.87623`, 65.72722`, 66.13831`, > 66.48902`, 66.06395`, 66.73532`, 67.12329`, 67.57161`, 68.18286`, > 68.33868`, 68.14658`, 69.17022`, 69.17597`, 68.52789`, 68.84874`, > 69.69833`, 69.86528`, 70.48646`, 71.16238`, 70.58946`, 70.54353`, > 72.38576`, 73.18522`, 64.12344`, 64.62855`, 65.74244`, 67.11563`, > 66.81497`, 68.38001`, 68.33835`, 68.25066`, 68.36488`, 68.67873`, > 68.70293`, 69.0466`, 70.17375`, 69.86849`, 70.15821`, 70.24204`, > 71.41811`, 70.66031`, 72.42614`, 73.04341`, 64.6891`, 67.09928`, > 67.79858`, 68.37299`, 69.19364`, 68.5938`, 69.86969`, 70.17952`, > 70.51811`, 71.00743`, 71.83086`, 72.81121`, 67.95451`, 67.81317`, > 69.32812`, 70.45127`, 71.38916`, 72.31022`, 71.8821`, 64.61601`, > 67.75382`, 69.90335`, 70.87039`, 72.71533`, 69.03942`, 72.44463`, > 69.07253`, 70.1758`, 72.37219`, 59.63777`, 73.27737`, 68.12621`, > 63.15234`, 66.00489`, 71.45303`, 68.1456`, 65.25527`, 70.41584`, > 68.38452`, 61.89133`, 64.98391`, 66.21887`, 59.48391`, 62.77645`, > 63.86507`, 64.56486`, 65.60265`, 66.28333`, 70.55256`, 62.14539`, > 64.37906`, 64.35191`, 64.91304`, 65.33085`, 65.17545`, 66.10285`, > 66.05004`, 67.38231`, 67.83999`, 70.27309`, 63.19263`, 63.66834`, > 64.12671`, 64.71388`, 65.14662`, 65.94428`, 65.67785`, 65.95134`, > 67.30819`, 66.69404`, 66.56885`, 66.80951`, 68.24011`, 67.5344`, > 68.4157`, 69.09588`, 70.81036`, 61.68183`, 63.04493`, 64.34945`, > 63.89336`, 65.48176`, 64.726`, 64.65128`, 67.47271`, 66.76701`, > 64.98147`, 69.38684`, 63.7123`, 64.63358`, 66.00037`, 65.96621`, > 66.49751`, 66.27177`, 65.67892`, 66.86814`, 66.73495`, 66.53357`, > 67.05051`, 67.04958`, 67.55908`, 67.58076`, 67.51942`, 68.12592`, > 68.57465`, 68.52484`, 69.20286`, 69.7551`, 69.91868`, 70.50329`, > 62.83528`, 63.24504`, 64.44602`, 64.31819`, 64.73521`, 64.72352`, > 65.97741`, 65.63739`, 65.83449`, 65.87064`, 66.61001`, 66.75821`, > 66.77012`, 67.21373`, 67.09047`, 66.93359`, 68.03852`, 67.98476`, > 68.25046`, 68.26078`, 68.21235`, 68.54029`, 68.50469`, 69.13248`, > 69.21981`, 69.34385`, 69.41153`, 70.25056`, 69.68641`, 70.51091`, > 71.29598`, 72.20218`, 72.33929`, 62.91628`, 63.93525`, 64.59851`, > 65.47401`, 65.864`, 66.30684`, 65.77587`, 66.48386`, 67.31983`, > 67.39901`, 67.05939`, 68.45161`, 67.7061`, 68.08389`, 67.58923`, > 67.80388`, 69.25919`, 69.05302`, 68.70921`, 69.02788`, 68.94943`, > 68.81536`, 69.91801`, 70.45072`, 69.96349`, 69.75787`, 71.38281`, > 71.08122`, 72.74936`, 65.26855`, 66.01549`, 65.5142`, 65.62374`, > 65.92199`, 67.11129`, 66.89727`, 67.94195`, 67.7274`, 67.54999`, > 67.96013`, 68.83038`, 69.43917`, 68.55957`, 69.10638`, 70.4814`, > 69.92992`, 70.04238`, 69.56779`, 71.01077`, 70.62603`, 71.46383`, > 71.62112`, 73.87758`, 65.00573`, 66.30354`, 65.86743`, 66.86667`, > 67.15958`, 68.06904`, 67.57382`, 67.63354`, 69.41356`, 68.87192`, > 69.07779`, 69.81177`, 70.01463`, 69.56649`, 70.254`, 70.68296`, > 70.87874`, 72.45099`, 73.04359`, 74.40915`, 67.40139`, 66.53122`, > 68.04593`, 68.82772`, 69.33069`, 70.34676`, 70.173`, 70.80883`, > 70.7029`, 72.35959`, 72.3661`, 67.17534`, 67.84045`, 68.9053`, > 70.3752`, 71.18523`, 71.41254`, 71.70673`, 72.60072`, 67.57652`, > 68.55814`, 70.95019`, 71.99783`, 75.17469`, 73.07157`, 69.92407`, > 65.54323`, 72.56261`, 72.15051`, 63.22006`, 73.2645`, 65.81296`, > 67.70657`, 66.99681`, 71.33181`, 71.78314`, 70.73837`, 70.30609`}; > > In[59]:= GaltonY = {59.77827`, 63.21404`, 63.34242`, 62.79238`, > 64.28113`, 64.24221`, 64.08231`, 63.99574`, 64.61338`, 63.97944`, > 65.24451`, 65.35102`, 65.67992`, 65.43664`, 65.29391`, 64.79017`, > 65.01881`, 65.5464`, 65.08145`, 65.49008`, 65.1352`, 65.51262`, > 66.58436`, 66.37842`, 66.14782`, 65.97259`, 65.95887`, 66.45202`, > 65.74797`, 65.97164`, 65.90548`, 65.90773`, 66.47103`, 65.75023`, > 66.34666`, 66.08577`, 66.28037`, 66.34354`, 66.41711`, 67.22558`, > 67.46394`, 66.99362`, 66.76647`, 67.0342`, 66.84316`, 69.2989`, > 69.09114`, 61.66358`, 65.7288`, 68.98012`, 67.37397`, 67.17459`, > 67.06712`, 67.29446`, 67.62665`, 67.47923`, 66.92162`, 67.58324`, > 67.21191`, 66.81629`, 67.24268`, 67.51036`, 67.57026`, 67.17258`, > 67.54129`, 67.37113`, 67.59714`, 67.25104`, 66.82533`, 66.72679`, > 66.92996`, 67.64847`, 68.04291`, 68.4885`, 68.04777`, 68.34573`, > 68.33829`, 68.3138`, 68.18333`, 68.51056`, 68.12014`, 68.31563`, > 68.04774`, 68.61273`, 67.9425`, 68.08381`, 68.36754`, 67.85181`, > 68.19806`, 68.01897`, 68.23431`, 67.89742`, 68.62409`, 67.97912`, > 68.2668`, 67.94192`, 68.62072`, 68.23857`, 68.58554`, 68.06568`, > 68.38188`, 67.75943`, 68.59991`, 67.91483`, 67.83861`, 68.77562`, > 69.60782`, 69.69143`, 69.41491`, 69.68931`, 69.20775`, 69.45627`, > 69.59614`, 69.27994`, 69.52338`, 68.74406`, 69.30987`, 69.22571`, > 69.24073`, 69.4912`, 69.11921`, 68.93751`, 69.45774`, 69.27599`, > 69.22869`, 68.70547`, 69.34638`, 68.87137`, 69.30262`, 69.1579`, > 69.62727`, 69.11014`, 69.09596`, 69.03281`, 69.85677`, 70.06274`, > 69.89765`, 70.26185`, 70.52663`, 70.52744`, 69.7865`, 70.36684`, > 69.97604`, 69.83308`, 70.69951`, 70.16871`, 70.11632`, 69.95433`, > 70.31279`, 69.80903`, 69.96792`, 69.93939`, 69.73486`, 70.08397`, > 70.01015`, 70.65025`, 70.01253`, 70.09077`, 71.34319`, 70.81542`, > 71.44929`, 71.18676`, 71.66276`, 71.39516`, 70.73612`, 71.2608`, > 71.04721`, 71.2592`, 70.89486`, 71.31732`, 71.55712`, 71.17701`, > 71.03412`, 71.37275`, 71.64741`, 71.1205`, 70.91756`, 71.66455`, > 72.39198`, 71.87928`, 72.34482`, 72.17265`, 72.52078`, 71.98836`, > 72.34482`, 72.45347`, 72.26945`, 71.96844`, 72.18169`, 72.7864`, > 73.0414`, 72.87858`, 73.17304`, 73.63274`, 72.88245`, 73.18148`, > 74.3209`, 74.40727`, 73.76791`, 73.92119`, 73.75503`, 75.56214`, > 75.70222`, 77.21338`, 61.28882`, 74.28343`, 70.93102`, 75.34802`, > 61.78758`, 64.00009`, 62.4658`, 73.70465`, 66.3495`, 62.20543`, > 65.421`, 63.9922`, 62.78458`, 63.52486`, 63.49966`, 62.89658`, > 63.72784`, 63.73231`, 64.39579`, 63.70072`, 64.44796`, 64.2795`, > 65.18412`, 65.10118`, 65.56277`, 64.94454`, 65.14227`, 65.16843`, > 65.58149`, 65.63474`, 64.87191`, 65.4176`, 64.7231`, 65.84559`, > 65.77333`, 66.67371`, 66.54726`, 66.43228`, 66.3326`, 66.24935`, > 66.39759`, 66.69366`, 66.22114`, 66.43499`, 66.65758`, 65.76873`, > 66.20784`, 66.30166`, 65.81894`, 66.34562`, 66.88369`, 66.8162`, > 67.36245`, 67.68308`, 67.19885`, 67.26903`, 67.45131`, 68.95907`, > 62.013`, 64.10658`, 66.00879`, 65.77796`, 66.94446`, 66.81229`, > 67.01431`, 67.43705`, 66.8442`, 67.25391`, 67.52273`, 67.17782`, > 67.6068`, 66.8991`, 66.74675`, 67.16928`, 67.23833`, 66.75589`, > 66.79828`, 67.488`, 67.1104`, 67.06455`, 66.93899`, 67.54723`, > 66.85662`, 67.70971`, 67.88296`, 68.66534`, 68.58164`, 68.44493`, > 68.41199`, 68.44665`, 68.38258`, 67.92987`, 68.3033`, 67.97479`, > 68.18304`, 68.57984`, 68.56974`, 67.81854`, 67.8796`, 68.22794`, > 68.01258`, 67.85023`, 67.80077`, 68.59968`, 68.08671`, 67.87656`, > 68.47849`, 68.60006`, 68.07838`, 68.08199`, 67.73211`, 68.4132`, > 68.59541`, 68.28458`, 68.06489`, 68.41445`, 69.36998`, 69.00435`, > 69.37297`, 68.89496`, 69.37382`, 69.34415`, 68.96686`, 69.59887`, > 69.24597`, 69.68301`, 68.90541`, 69.07283`, 69.03297`, 69.18202`, > 69.64233`, 68.82818`, 69.24165`, 69.10265`, 68.98512`, 69.31551`, > 69.20435`, 68.93765`, 69.36661`, 68.71181`, 68.75662`, 69.35439`, > 69.74222`, 69.82326`, 69.90223`, 70.2992`, 69.83745`, 69.94847`, > 70.27479`, 70.67752`, 70.38903`, 70.37578`, 70.60668`, 70.16921`, > 69.85223`, 70.23353`, 70.28373`, 70.33881`, 69.81443`, 70.54739`, > 69.96746`, 69.73702`, 69.8604`, 70.87111`, 71.36657`, 71.1878`, > 70.75001`, 70.72998`, 71.32092`, 70.88794`, 70.9085`, 70.87662`, > 71.19803`, 71.31925`, 71.22916`, 71.35939`, 71.60205`, 70.97309`, > 71.1886`, 71.40319`, 71.39524`, 70.88752`, 71.27449`, 72.10289`, > 72.03197`, 71.9969`, 71.72577`, 71.92914`, 72.20518`, 72.29401`, > 72.5854`, 72.04673`, 71.80541`, 71.80464`, 73.06559`, 73.44548`, > 73.19223`, 73.37471`, 73.22554`, 72.88357`, 72.77826`, 73.26989`, > 73.96165`, 74.64342`, 73.92565`, 74.58767`, 74.31029`, 75.10003`, > 77.15504`, 60.78204`, 62.36303`, 66.40186`, 58.50708`, 70.00052`, > 70.99433`, 64.96417`, 70.47639`, 69.23383`, 64.90184`, 68.7749`, > 69.85805`, 62.52373`, 63.28805`, 63.52861`, 62.87456`, 63.91754`, > 64.32325`, 64.22405`, 64.59643`, 64.28548`, 63.78835`, 65.66404`, > 64.80838`, 65.63528`, 64.74897`, 64.79081`, 65.10988`, 65.55215`, > 65.30083`, 65.1426`, 65.09433`, 64.81397`, 65.95058`, 66.37511`, > 66.38624`, 66.31904`, 65.80919`, 66.09556`, 66.49077`, 66.32632`, > 66.59779`, 66.00909`, 66.45585`, 66.00818`, 66.46605`, 66.37783`, > 66.34685`, 66.31558`, 66.62303`, 66.79229`, 67.5336`, 67.15587`, > 66.78051`, 67.25544`, 66.79006`, 66.88298`, 68.1121`, 63.61572`, > 63.17978`, 65.67211`, 67.23403`, 67.4089`, 67.57913`, 67.20643`, > 67.10018`, 66.80557`, 67.09308`, 66.91372`, 66.77528`, 66.97572`, > 67.66639`, 67.62089`, 67.66841`, 67.32572`, 67.04153`, 66.96445`, > 67.07223`, 67.169`, 67.48077`, 67.67057`, 66.86465`, 67.04437`, > 67.72523`, 68.52969`, 67.8741`, 67.84693`, 68.26632`, 68.18364`, > 68.55723`, 67.77137`, 67.92976`, 67.72522`, 67.98916`, 68.0679`, > 67.772`, 68.11035`, 68.16623`, 68.61054`, 68.2893`, 68.38263`, > 68.6212`, 68.27802`, 67.93914`, 67.7105`, 68.351`, 68.14712`, > 67.97421`, 68.23682`, 68.05699`, 68.49856`, 68.58894`, 67.74098`, > 68.69765`, 68.63531`, 68.37844`, 69.11352`, 69.35385`, 69.5135`, > 69.11`, 69.64324`, 69.40655`, 69.18575`, 68.80709`, 69.11679`, > 69.02706`, 69.05703`, 69.14581`, 68.7308`, 68.9798`, 68.95303`, > 69.1639`, 68.81649`, 68.73746`, 69.00102`, 69.28222`, 69.37676`, > 68.90879`, 69.32318`, 69.63872`, 69.43581`, 68.97885`, 69.54252`, > 68.73497`, 69.20127`, 70.36167`, 70.10118`, 70.39507`, 70.03877`, > 69.76556`, 70.39131`, 70.0372`, 70.25908`, 69.87081`, 70.69845`, > 70.25756`, 69.7177`, 70.31993`, 69.95735`, 69.72691`, 70.22698`, > 70.02038`, 70.32035`, 70.39947`, 69.78074`, 69.7598`, 70.53827`, > 70.03449`, 70.59135`, 71.13378`, 71.15371`, 71.03018`, 70.93936`, > 70.78603`, 71.50695`, 71.57023`, 70.83563`, 70.96118`, 71.55428`, > 71.08274`, 71.49587`, 71.36997`, 71.49891`, 71.01177`, 71.62784`, > 71.36701`, 71.23426`, 70.90129`, 71.53087`, 72.441`, 72.5999`, > 71.79167`, 72.00806`, 72.01746`, 72.44981`, 71.92864`, 72.0908`, > 72.57398`, 72.53335`, 71.78483`, 72.57594`, 73.06795`, 73.18852`, > 73.39371`, 73.3754`, 73.67679`, 72.84789`, 72.99608`, 74.67822`, > 73.8507`, 74.35692`, 73.99906`, 73.92525`, 75.67784`, 76.10484`, > 78.2476`, 61.89619`, 69.86215`, 62.26801`, 71.40839`, 71.60925`, > 65.51351`, 71.86574`, 71.16645`, 64.53321`, 65.25053`, 69.62871`, > 65.10223`, 61.03526`, 63.12132`, 63.5968`, 63.47848`, 63.83162`, > 64.18388`, 64.66888`, 64.06363`, 64.38072`, 64.60295`, 64.81735`, > 65.22864`, 65.62354`, 65.62755`, 64.8584`, 65.6482`, 65.6904`, > 65.58218`, 65.08945`, 64.87234`, 65.68794`, 66.54461`, 66.23255`, > 65.91034`, 66.29882`, 66.33603`, 66.19024`, 66.12728`, 66.1938`, > 65.82389`, 66.61389`, 66.45299`, 66.25633`, 66.53703`, 66.28457`, > 65.90354`, 66.61969`, 66.59349`, 67.30641`, 67.41523`, 67.51658`, > 66.94071`, 67.11246`, 66.99107`, 66.94124`, 68.06898`, 67.47908`, > 63.00731`, 67.40208`, 68.75691`, 66.90827`, 67.28305`, 67.15978`, > 67.12405`, 67.07313`, 67.17665`, 66.74724`, 66.81865`, 67.43735`, > 67.37322`, 66.96049`, 67.40154`, 66.91834`, 66.93007`, 66.78425`, > 66.7842`, 67.15158`, 67.45025`, 67.68985`, 67.13767`, 67.60589`, > 67.96334`, 68.65674`, 68.42972`, 68.01111`, 68.61891`, 68.50647`, > 67.77439`, 68.09837`, 68.19228`, 68.54918`, 68.59413`, 68.65282`, > 68.40294`, 68.54259`, 68.59444`, 67.87885`, 68.0454`, 67.96346`, > 68.55092`, 68.07785`, 67.93252`, 68.5916`, 67.90891`, 68.63842`, > 68.6514`, 68.40634`, 68.19563`, 68.3391`, 68.13175`, 67.79551`, > 68.24471`, 67.96366`, 68.02669`, 68.07695`, 69.23339`, 69.22874`, > 68.9062`, 69.33247`, 69.53206`, 69.02418`, 69.26288`, 69.55433`, > 69.3664`, 68.96569`, 69.33038`, 69.10425`, 69.29199`, 69.26009`, > 68.71424`, 69.48488`, 69.48141`, 68.88311`, 68.83524`, 69.42378`, > 68.82387`, 69.06951`, 69.18528`, 69.26989`, 68.83727`, 69.11594`, > 69.39569`, 68.70258`, 70.39288`, 70.49606`, 70.11817`, 69.75304`, > 70.25238`, 70.28837`, 69.71807`, 70.13835`, 70.41752`, 69.91638`, > 69.7803`, 69.90789`, 70.29221`, 70.20136`, 70.42766`, 70.40239`, > 70.65713`, 69.7276`, 70.45174`, 70.52536`, 70.45682`, 70.52011`, > 70.25621`, 70.32714`, 71.39933`, 71.03487`, 71.61276`, 70.90129`, > 71.36831`, 71.46158`, 71.22939`, 71.59368`, 71.6476`, 71.33885`, > 71.13133`, 71.52388`, 70.95837`, 71.48199`, 70.85433`, 71.41922`, > 71.30872`, 71.22321`, 71.4506`, 70.76122`, 72.65576`, 71.96434`, > 72.3071`, 72.2446`, 72.38029`, 72.04211`, 71.77644`, 72.54877`, > 72.57381`, 71.90584`, 72.62022`, 72.4218`, 73.13823`, 73.60773`, > 73.2649`, 73.0769`, 73.69792`, 73.60551`, 72.87015`, 73.90142`, > 74.32431`, 73.87776`, 74.20972`, 74.47833`, 75.07304`, 76.3516`, > 78.36479`, 61.22021`, 72.63356`, 64.94291`, 73.02984`, 71.81569`, > 65.29123`, 60.90911`, 72.131`, 70.98853`, 61.7019`, 67.51436`, > 64.37789`, 63.2825`, 63.47892`, 63.66235`, 63.94637`, 63.93831`, > 63.94722`, 64.08187`, 64.68702`, 64.38337`, 63.91132`, 64.84282`, > 65.33216`, 65.2375`, 65.47348`, 65.16309`, 65.35727`, 65.59545`, > 64.70258`, 64.76966`, 65.55892`, 65.42338`, 66.54624`, 65.70133`, > 66.12315`, 66.2678`, 66.55539`, 66.42398`, 66.50633`, 66.27712`, > 66.42142`, 66.25827`, 66.1285`, 66.53558`, 66.32575`, 66.11991`, > 65.87925`, 65.70978`, 66.10198`, 67.57237`, 67.4361`, 67.00761`, > 67.21048`, 67.1921`, 67.39528`, 67.44979`, 68.18883`, 62.74094`, > 66.34954`, 65.69966`, 68.36264`, 67.52548`, 67.24632`, 67.21519`, > 67.45383`, 66.93472`, 67.6832`, 66.97218`, 66.73049`, 66.75153`, > 67.4346`, 66.92896`, 67.49282`, 66.93944`, 67.03135`, 66.91542`, > 66.97758`, 67.14932`, 67.53093`, 67.52202`, 67.27928`, 67.56893`, > 67.75773`, 68.10565`, 68.49664`, 68.5851`, 67.85579`, 68.60796`, > 68.19156`, 68.25828`, 68.15401`, 68.18623`, 68.16064`, 68.6097`, > 68.34391`, 68.65678`, 68.51914`, 67.72093`, 67.96986`, 67.75073`, > 68.09745`, 68.64602`, 68.2318`, 68.18244`, 68.15011`, 68.13611`, > 68.10048`, 68.53037`, 68.37728`, 68.17652`, 67.7452`, 67.93037`, > 68.25872`, 68.33639`, 68.27405`, 69.5816`, 68.70027`, 68.93075`, > 68.78663`, 69.0649`, 68.99285`, 68.99516`, 68.73929`, 69.47357`, > 69.08392`, 69.07281`, 69.62286`, 69.35683`, 69.16149`, 68.81413`, > 68.9529`, 69.47561`, 69.5506`, 69.38889`, 69.57241`, 69.37092`, > 68.92229`, 68.71081`, 69.2671`, 68.74473`, 68.81509`, 69.47472`, > 69.69307`, 69.65334`, 70.46902`, 70.00607`, 70.61711`, 70.51318`, > 69.97204`, 69.92313`, 70.46938`, 69.91923`, 69.71908`, 70.61155`, > 70.20868`, 70.27586`, 70.18348`, 70.5115`, 70.50015`, 70.24017`, > 70.001`, 70.21726`, 70.20554`, 69.97788`, 70.36632`, 70.38931`, > 70.18593`, 70.23168`, 70.74197`, 71.47899`, 71.41695`, 71.20207`, > 70.87987`, 71.26557`, 71.41653`, 71.24074`, 71.15528`, 71.20588`, > 70.98515`, 71.35642`, 71.21331`, 71.59639`, 71.25854`, 71.53325`, > 70.92787`, 71.54787`, 71.07293`, 70.86163`, 72.67319`, 71.77245`, > 72.64278`, 72.48159`, 71.9078`, 72.18324`, 72.55104`, 72.33861`, > 72.07098`, 72.30647`, 72.05185`, 72.75204`, 72.79178`, 73.50606`, > 73.68578`, 72.79593`, 73.41049`, 73.02077`, 73.20758`, 74.49237`, > 73.81263`, 73.81376`, 73.82642`, 73.81739`, 75.57544`, 77.23474`, > 60.05859`, 76.81927`, 66.72684`, 58.79456`, 67.89277`, 61.04946`, > 59.81693`, 70.75232`, 68.26774`, 69.30589`, 69.30199`, 67.015`}; > > In[60]:= lm = LinearModelFit[GaltonDat, {1, x}, x] > > Out[60]= FittedModel[\\!\\(\\* > PanelBox[ > TagBox[ > RowBox[{\33.88660435407788`\, \ \, \+\, > RowBox[{\0.5140930386233082`\, \ \, \x\}]}], > Short], > FrameMargins->5]\\)] > > In[62]:= lm[\BestFit\] > > Out[62]= 33.8866 + 0.514093 x > > In[63]:= r2 = Correlation[GaltonX, GaltonY] > > Out[63]= 0.501338 > === Subject: Re: Difference Fit vs. Correlation can you explain what \using Fit\ mean lm[\RSquared\] // Sqrt gives 0.501338 and this corresponds to the correlation value. Jens > in the code below, using Correlation I get 0.501338, using Fit I get > 0.514093. > How come? > > Claus > > > In[47]:= GaltonX = {65.04851`, 63.25094`, 64.95532`, 65.7525`, > 61.13723`, 63.02254`, 65.37053`, 64.72398`, 66.06509`, 66.96738`, > 59.008`, 62.93203`, 63.67063`, 64.07386`, 64.68851`, 65.15466`, > 66.37353`, 65.57704`, 67.36765`, 66.75929`, 67.79764`, 69.5348`, > 62.54014`, 63.81016`, 64.4565`, 64.9665`, 64.70662`, 65.73829`, > 65.50141`, 65.55416`, 66.90294`, 66.57388`, 66.53198`, 67.90613`, > 68.29198`, 67.74123`, 68.46917`, 69.38327`, 71.81791`, 62.41615`, > 64.49083`, 64.4876`, 63.92303`, 65.44592`, 65.02977`, 65.67038`, > 68.66078`, 66.54597`, 64.85954`, 69.60692`, 64.8135`, 65.32703`, > 65.83169`, 65.83427`, 65.56135`, 65.8688`, 65.77339`, 67.09116`, > 66.61374`, 67.41075`, 67.27716`, 66.61134`, 68.17412`, 67.80555`, > 68.32529`, 68.07787`, 68.96795`, 68.9255`, 69.60862`, 70.35646`, > 70.00643`, 72.75425`, 62.82147`, 62.86855`, 63.91261`, 64.54118`, > 64.51906`, 66.02688`, 65.81011`, 66.01812`, 65.53742`, 65.73346`, > 66.77424`, 66.67869`, 66.97585`, 66.94021`, 66.84575`, 67.12008`, > 67.74181`, 68.27194`, 67.60691`, 68.44737`, 67.65832`, 68.71193`, > 69.32025`, 68.7403`, 69.13395`, 69.34995`, 68.6297`, 69.58258`, > 70.39517`, 71.19284`, 70.82429`, 71.65367`, 73.28133`, 63.03753`, > 63.66428`, 65.38311`, 64.60205`, 66.40661`, 65.76985`, 65.66729`, > 66.05712`, 66.54635`, 66.5723`, 66.64876`, 67.71899`, 68.48726`, > 67.82769`, 67.55801`, 68.07763`, 69.16715`, 68.693`, 68.61779`, > 68.64797`, 68.61666`, 70.36485`, 70.0099`, 70.13984`, 70.2073`, > 71.28063`, 70.90445`, 72.19036`, 74.96203`, 64.88218`, 65.55174`, > 65.65889`, 65.92826`, 65.94198`, 67.43646`, 67.48444`, 67.61344`, > 68.4518`, 68.49456`, 68.1056`, 69.48308`, 69.07389`, 69.39251`, > 69.44294`, 69.52131`, 70.15463`, 69.86911`, 70.44394`, 70.85393`, > 71.30074`, 72.13978`, 72.19045`, 75.43393`, 64.51788`, 66.36335`, > 65.56855`, 66.78957`, 66.91193`, 68.1714`, 67.50102`, 67.83492`, > 68.95255`, 69.26`, 68.74223`, 69.74288`, 70.29942`, 70.04402`, > 70.23559`, 70.88075`, 71.19091`, 72.37396`, 73.03345`, 74.8083`, > 67.39521`, 67.31523`, 67.77952`, 69.33827`, 68.72404`, 69.98991`, > 69.75383`, 70.65942`, 71.10882`, 72.4811`, 72.4801`, 67.52214`, > 68.23931`, 68.7997`, 69.89568`, 71.48641`, 70.76482`, 71.9137`, > 63.08399`, 68.23241`, 70.05787`, 70.83996`, 72.56944`, 67.93353`, > 67.54033`, 72.79855`, 62.67482`, 68.19196`, 65.07215`, 73.42952`, > 62.94125`, 62.53667`, 69.90248`, 71.07217`, 71.11059`, 69.48402`, > 70.18338`, 65.46124`, 62.04073`, 63.60063`, 65.60613`, 68.02969`, > 61.81571`, 63.78886`, 64.89023`, 65.79072`, 66.42371`, 68.80877`, > 61.76521`, 64.30302`, 63.69064`, 64.99662`, 65.34899`, 64.81278`, > 65.71736`, 66.03148`, 67.04912`, 67.77522`, 69.04964`, 62.1833`, > 62.76393`, 63.88391`, 65.41055`, 64.62347`, 65.64621`, 66.16257`, > 65.99538`, 65.79786`, 67.42936`, 67.11933`, 67.32907`, 67.86233`, > 68.31609`, 67.96359`, 68.68615`, 71.18085`, 62.4296`, 62.88524`, > 64.07313`, 63.88597`, 64.8272`, 65.39653`, 64.77344`, 68.66581`, > 65.19783`, 64.32621`, 66.08278`, 69.01679`, 64.50194`, 66.07654`, > 65.73631`, 66.45485`, 65.63018`, 66.39423`, 67.33687`, 66.83938`, > 66.69739`, 67.34708`, 67.35319`, 67.93575`, 67.76608`, 68.11569`, > 68.2548`, 68.83427`, 69.40758`, 69.32068`, 70.48`, 70.06429`, > 70.63764`, 62.41134`, 63.15274`, 63.51409`, 63.91446`, 64.61683`, > 64.86185`, 65.91332`, 66.1992`, 66.45978`, 65.50286`, 66.87795`, > 67.0791`, 66.83256`, 67.18231`, 66.51763`, 66.95295`, 66.63586`, > 68.18453`, 67.60565`, 68.27918`, 67.97994`, 69.00094`, 69.31139`, > 68.88641`, 68.94824`, 69.42186`, 69.49516`, 70.34647`, 69.92358`, > 70.69078`, 70.56571`, 72.40997`, 72.47685`, 62.72118`, 63.9001`, > 64.50433`, 64.81813`, 65.37582`, 65.82612`, 66.29436`, 65.81042`, > 66.80854`, 67.16724`, 67.30525`, 67.54577`, 67.86855`, 68.35003`, > 67.60818`, 68.48397`, 68.56724`, 69.07405`, 68.56831`, 69.15373`, > 68.60744`, 68.5443`, 69.65536`, 70.41632`, 69.97528`, 70.26613`, > 71.31667`, 71.29178`, 72.59442`, 64.40268`, 64.9127`, 66.34756`, > 66.04291`, 65.69477`, 66.71512`, 66.64971`, 68.33241`, 67.94335`, > 67.96734`, 68.27657`, 68.75008`, 69.05441`, 69.00755`, 69.39488`, > 69.7628`, 69.6464`, 70.45427`, 69.89852`, 70.984`, 71.22015`, > 71.45442`, 71.60966`, 73.20296`, 63.89132`, 65.99384`, 66.0424`, > 67.47658`, 66.68527`, 68.27034`, 67.72898`, 68.28372`, 68.39453`, > 69.12925`, 69.10844`, 69.74196`, 69.9987`, 69.56148`, 69.97779`, > 70.88691`, 70.64687`, 72.26404`, 71.50569`, 73.01402`, 66.20254`, > 67.26312`, 67.8086`, 69.08284`, 69.35107`, 69.59962`, 70.08948`, > 70.18385`, 71.26955`, 72.07717`, 72.33894`, 67.06776`, 67.85929`, > 69.07274`, 69.59893`, 69.73728`, 70.54066`, 72.40962`, 72.78889`, > 68.10144`, 68.6106`, 71.293`, 72.09445`, 74.69236`, 71.16246`, > 68.30804`, 60.41857`, 63.94459`, 63.06849`, 63.98036`, 73.89524`, > 72.03687`, 61.02471`, 65.39914`, 71.96564`, 71.29643`, 65.15837`, > 68.90263`, 64.45192`, 63.99469`, 66.46124`, 67.12556`, 62.27941`, > 63.8488`, 65.43612`, 65.62145`, 66.16956`, 67.62675`, 60.21393`, > 62.99378`, 63.57239`, 65.15088`, 65.13462`, 64.79732`, 66.24856`, > 66.22743`, 66.6056`, 67.99167`, 69.04862`, 62.12902`, 63.16227`, > 64.45497`, 63.75483`, 64.63959`, 64.59106`, 66.06003`, 65.98544`, > 65.66176`, 67.11501`, 67.31302`, 67.16149`, 68.38679`, 67.64175`, > 67.55466`, 68.53614`, 70.02702`, 61.07412`, 62.72387`, 64.28642`, > 64.11073`, 63.68318`, 64.68393`, 64.66753`, 67.95848`, 64.60933`, > 66.07775`, 65.25267`, 69.67201`, 65.33965`, 65.54375`, 66.1112`, > 66.22968`, 66.00879`, 66.03248`, 65.94624`, 67.09734`, 66.98893`, > 67.38837`, 67.4075`, 67.31108`, 68.27151`, 68.33586`, 67.56752`, > 68.23182`, 69.07604`, 68.77033`, 70.49154`, 70.00767`, 69.52007`, > 61.50617`, 62.93875`, 64.10318`, 63.85157`, 65.08731`, 64.62588`, > 65.8912`, 66.24386`, 65.66031`, 66.05344`, 66.30711`, 67.15303`, > 66.90986`, 66.89436`, 66.56566`, 67.23789`, 67.05684`, 67.94515`, > 67.94026`, 67.84234`, 67.91887`, 68.63961`, 68.60477`, 69.04036`, > 69.03336`, 69.12497`, 68.53779`, 70.24335`, 69.84308`, 69.90057`, > 71.48946`, 72.37013`, 71.94413`, 61.01904`, 63.0108`, 64.5793`, > 65.39658`, 64.84995`, 65.54542`, 65.56421`, 66.09747`, 67.40602`, > 66.5839`, 67.41035`, 67.21634`, 68.23175`, 67.88053`, 68.0153`, > 67.69332`, 68.85462`, 68.73264`, 69.0711`, 68.79964`, 68.79876`, > 69.32241`, 69.60923`, 69.76071`, 70.1611`, 70.12109`, 71.10802`, > 71.44164`, 71.75006`, 64.35591`, 65.16253`, 66.09529`, 65.78674`, > 65.53927`, 66.71703`, 67.17284`, 67.16853`, 68.06061`, 67.85988`, > 68.1968`, 69.29537`, 68.84067`, 69.18095`, 68.69659`, 69.45833`, > 70.0483`, 69.6916`, 70.20658`, 70.79086`, 70.87977`, 71.30702`, > 72.3266`, 72.7824`, 64.40052`, 64.89121`, 65.84506`, 67.35461`, > 67.44953`, 67.86439`, 67.92443`, 68.49998`, 67.60602`, 69.37288`, > 69.34931`, 69.48306`, 70.21887`, 70.02161`, 69.83698`, 69.6041`, > 71.49829`, 72.16894`, 72.41045`, 72.52521`, 64.6702`, 66.78417`, > 67.83401`, 68.15907`, 69.19301`, 68.86739`, 70.11126`, 70.12007`, > 71.03691`, 71.43196`, 72.04564`, 72.738`, 68.02564`, 69.04939`, > 68.86356`, 69.63421`, 71.24085`, 71.95679`, 72.89983`, 65.86028`, > 68.48883`, 70.72676`, 72.34582`, 72.59922`, 68.82986`, 73.49987`, > 70.0599`, 67.9291`, 64.66998`, 60.7795`, 74.94058`, 70.64925`, > 60.91526`, 65.28934`, 71.362`, 71.66893`, 62.68868`, 71.39326`, > 66.56302`, 67.18788`, 62.532`, 64.85512`, 66.94161`, 62.3603`, > 63.58145`, 65.44633`, 65.00539`, 66.43717`, 66.6676`, 59.4898`, > 63.00108`, 64.0892`, 64.0753`, 64.52103`, 65.19231`, 66.30604`, > 66.03081`, 66.83096`, 68.19724`, 68.6599`, 61.29369`, 63.26089`, > 63.86162`, 64.13176`, 64.81105`, 64.55987`, 66.19437`, 66.5`, > 66.43436`, 67.30468`, 67.36559`, 67.29162`, 67.69874`, 68.38221`, > 67.76712`, 69.29587`, 69.66477`, 60.03436`, 62.1356`, 63.64047`, > 63.82278`, 64.46555`, 64.73798`, 65.43021`, 65.07381`, 69.29517`, > 67.67996`, 64.94267`, 69.47933`, 65.05963`, 65.01253`, 65.61963`, > 65.94819`, 65.68803`, 65.87689`, 65.91481`, 67.41946`, 66.53833`, > 67.41995`, 67.21977`, 67.33721`, 68.11283`, 68.02017`, 68.02829`, > 68.35139`, 68.80254`, 69.49307`, 70.2297`, 69.71997`, 70.16651`, > 61.07369`, 62.66947`, 64.32254`, 64.27362`, 64.96148`, 64.77222`, > 66.2365`, 66.10686`, 66.42772`, 66.22727`, 65.87574`, 67.03017`, > 67.48545`, 66.7367`, 66.69181`, 67.31766`, 67.1219`, 67.82592`, > 68.4376`, 67.74551`, 68.0934`, 67.71665`, 68.99349`, 69.24616`, > 69.2828`, 69.26254`, 68.75605`, 69.62519`, 69.61942`, 69.94715`, > 70.58916`, 72.34058`, 71.56142`, 72.94457`, 63.33777`, 64.3445`, > 65.14077`, 65.2424`, 65.90397`, 65.98763`, 65.57065`, 65.82733`, > 66.88576`, 66.98594`, 67.41537`, 67.93319`, 67.77812`, 68.44999`, > 68.32281`, 68.35148`, 68.73678`, 68.97673`, 69.31931`, 68.80442`, > 68.90434`, 69.80381`, 69.66712`, 70.38052`, 70.29892`, 71.02634`, > 71.28432`, 72.03259`, 63.26539`, 64.87623`, 65.72722`, 66.13831`, > 66.48902`, 66.06395`, 66.73532`, 67.12329`, 67.57161`, 68.18286`, > 68.33868`, 68.14658`, 69.17022`, 69.17597`, 68.52789`, 68.84874`, > 69.69833`, 69.86528`, 70.48646`, 71.16238`, 70.58946`, 70.54353`, > 72.38576`, 73.18522`, 64.12344`, 64.62855`, 65.74244`, 67.11563`, > 66.81497`, 68.38001`, 68.33835`, 68.25066`, 68.36488`, 68.67873`, > 68.70293`, 69.0466`, 70.17375`, 69.86849`, 70.15821`, 70.24204`, > 71.41811`, 70.66031`, 72.42614`, 73.04341`, 64.6891`, 67.09928`, > 67.79858`, 68.37299`, 69.19364`, 68.5938`, 69.86969`, 70.17952`, > 70.51811`, 71.00743`, 71.83086`, 72.81121`, 67.95451`, 67.81317`, > 69.32812`, 70.45127`, 71.38916`, 72.31022`, 71.8821`, 64.61601`, > 67.75382`, 69.90335`, 70.87039`, 72.71533`, 69.03942`, 72.44463`, > 69.07253`, 70.1758`, 72.37219`, 59.63777`, 73.27737`, 68.12621`, > 63.15234`, 66.00489`, 71.45303`, 68.1456`, 65.25527`, 70.41584`, > 68.38452`, 61.89133`, 64.98391`, 66.21887`, 59.48391`, 62.77645`, > 63.86507`, 64.56486`, 65.60265`, 66.28333`, 70.55256`, 62.14539`, > 64.37906`, 64.35191`, 64.91304`, 65.33085`, 65.17545`, 66.10285`, > 66.05004`, 67.38231`, 67.83999`, 70.27309`, 63.19263`, 63.66834`, > 64.12671`, 64.71388`, 65.14662`, 65.94428`, 65.67785`, 65.95134`, > 67.30819`, 66.69404`, 66.56885`, 66.80951`, 68.24011`, 67.5344`, > 68.4157`, 69.09588`, 70.81036`, 61.68183`, 63.04493`, 64.34945`, > 63.89336`, 65.48176`, 64.726`, 64.65128`, 67.47271`, 66.76701`, > 64.98147`, 69.38684`, 63.7123`, 64.63358`, 66.00037`, 65.96621`, > 66.49751`, 66.27177`, 65.67892`, 66.86814`, 66.73495`, 66.53357`, > 67.05051`, 67.04958`, 67.55908`, 67.58076`, 67.51942`, 68.12592`, > 68.57465`, 68.52484`, 69.20286`, 69.7551`, 69.91868`, 70.50329`, > 62.83528`, 63.24504`, 64.44602`, 64.31819`, 64.73521`, 64.72352`, > 65.97741`, 65.63739`, 65.83449`, 65.87064`, 66.61001`, 66.75821`, > 66.77012`, 67.21373`, 67.09047`, 66.93359`, 68.03852`, 67.98476`, > 68.25046`, 68.26078`, 68.21235`, 68.54029`, 68.50469`, 69.13248`, > 69.21981`, 69.34385`, 69.41153`, 70.25056`, 69.68641`, 70.51091`, > 71.29598`, 72.20218`, 72.33929`, 62.91628`, 63.93525`, 64.59851`, > 65.47401`, 65.864`, 66.30684`, 65.77587`, 66.48386`, 67.31983`, > 67.39901`, 67.05939`, 68.45161`, 67.7061`, 68.08389`, 67.58923`, > 67.80388`, 69.25919`, 69.05302`, 68.70921`, 69.02788`, 68.94943`, > 68.81536`, 69.91801`, 70.45072`, 69.96349`, 69.75787`, 71.38281`, > 71.08122`, 72.74936`, 65.26855`, 66.01549`, 65.5142`, 65.62374`, > 65.92199`, 67.11129`, 66.89727`, 67.94195`, 67.7274`, 67.54999`, > 67.96013`, 68.83038`, 69.43917`, 68.55957`, 69.10638`, 70.4814`, > 69.92992`, 70.04238`, 69.56779`, 71.01077`, 70.62603`, 71.46383`, > 71.62112`, 73.87758`, 65.00573`, 66.30354`, 65.86743`, 66.86667`, > 67.15958`, 68.06904`, 67.57382`, 67.63354`, 69.41356`, 68.87192`, > 69.07779`, 69.81177`, 70.01463`, 69.56649`, 70.254`, 70.68296`, > 70.87874`, 72.45099`, 73.04359`, 74.40915`, 67.40139`, 66.53122`, > 68.04593`, 68.82772`, 69.33069`, 70.34676`, 70.173`, 70.80883`, > 70.7029`, 72.35959`, 72.3661`, 67.17534`, 67.84045`, 68.9053`, > 70.3752`, 71.18523`, 71.41254`, 71.70673`, 72.60072`, 67.57652`, > 68.55814`, 70.95019`, 71.99783`, 75.17469`, 73.07157`, 69.92407`, > 65.54323`, 72.56261`, 72.15051`, 63.22006`, 73.2645`, 65.81296`, > 67.70657`, 66.99681`, 71.33181`, 71.78314`, 70.73837`, 70.30609`}; > > In[59]:= GaltonY = {59.77827`, 63.21404`, 63.34242`, 62.79238`, > 64.28113`, 64.24221`, 64.08231`, 63.99574`, 64.61338`, 63.97944`, > 65.24451`, 65.35102`, 65.67992`, 65.43664`, 65.29391`, 64.79017`, > 65.01881`, 65.5464`, 65.08145`, 65.49008`, 65.1352`, 65.51262`, > 66.58436`, 66.37842`, 66.14782`, 65.97259`, 65.95887`, 66.45202`, > 65.74797`, 65.97164`, 65.90548`, 65.90773`, 66.47103`, 65.75023`, > 66.34666`, 66.08577`, 66.28037`, 66.34354`, 66.41711`, 67.22558`, > 67.46394`, 66.99362`, 66.76647`, 67.0342`, 66.84316`, 69.2989`, > 69.09114`, 61.66358`, 65.7288`, 68.98012`, 67.37397`, 67.17459`, > 67.06712`, 67.29446`, 67.62665`, 67.47923`, 66.92162`, 67.58324`, > 67.21191`, 66.81629`, 67.24268`, 67.51036`, 67.57026`, 67.17258`, > 67.54129`, 67.37113`, 67.59714`, 67.25104`, 66.82533`, 66.72679`, > 66.92996`, 67.64847`, 68.04291`, 68.4885`, 68.04777`, 68.34573`, > 68.33829`, 68.3138`, 68.18333`, 68.51056`, 68.12014`, 68.31563`, > 68.04774`, 68.61273`, 67.9425`, 68.08381`, 68.36754`, 67.85181`, > 68.19806`, 68.01897`, 68.23431`, 67.89742`, 68.62409`, 67.97912`, > 68.2668`, 67.94192`, 68.62072`, 68.23857`, 68.58554`, 68.06568`, > 68.38188`, 67.75943`, 68.59991`, 67.91483`, 67.83861`, 68.77562`, > 69.60782`, 69.69143`, 69.41491`, 69.68931`, 69.20775`, 69.45627`, > 69.59614`, 69.27994`, 69.52338`, 68.74406`, 69.30987`, 69.22571`, > 69.24073`, 69.4912`, 69.11921`, 68.93751`, 69.45774`, 69.27599`, > 69.22869`, 68.70547`, 69.34638`, 68.87137`, 69.30262`, 69.1579`, > 69.62727`, 69.11014`, 69.09596`, 69.03281`, 69.85677`, 70.06274`, > 69.89765`, 70.26185`, 70.52663`, 70.52744`, 69.7865`, 70.36684`, > 69.97604`, 69.83308`, 70.69951`, 70.16871`, 70.11632`, 69.95433`, > 70.31279`, 69.80903`, 69.96792`, 69.93939`, 69.73486`, 70.08397`, > 70.01015`, 70.65025`, 70.01253`, 70.09077`, 71.34319`, 70.81542`, > 71.44929`, 71.18676`, 71.66276`, 71.39516`, 70.73612`, 71.2608`, > 71.04721`, 71.2592`, 70.89486`, 71.31732`, 71.55712`, 71.17701`, > 71.03412`, 71.37275`, 71.64741`, 71.1205`, 70.91756`, 71.66455`, > 72.39198`, 71.87928`, 72.34482`, 72.17265`, 72.52078`, 71.98836`, > 72.34482`, 72.45347`, 72.26945`, 71.96844`, 72.18169`, 72.7864`, > 73.0414`, 72.87858`, 73.17304`, 73.63274`, 72.88245`, 73.18148`, > 74.3209`, 74.40727`, 73.76791`, 73.92119`, 73.75503`, 75.56214`, > 75.70222`, 77.21338`, 61.28882`, 74.28343`, 70.93102`, 75.34802`, > 61.78758`, 64.00009`, 62.4658`, 73.70465`, 66.3495`, 62.20543`, > 65.421`, 63.9922`, 62.78458`, 63.52486`, 63.49966`, 62.89658`, > 63.72784`, 63.73231`, 64.39579`, 63.70072`, 64.44796`, 64.2795`, > 65.18412`, 65.10118`, 65.56277`, 64.94454`, 65.14227`, 65.16843`, > 65.58149`, 65.63474`, 64.87191`, 65.4176`, 64.7231`, 65.84559`, > 65.77333`, 66.67371`, 66.54726`, 66.43228`, 66.3326`, 66.24935`, > 66.39759`, 66.69366`, 66.22114`, 66.43499`, 66.65758`, 65.76873`, > 66.20784`, 66.30166`, 65.81894`, 66.34562`, 66.88369`, 66.8162`, > 67.36245`, 67.68308`, 67.19885`, 67.26903`, 67.45131`, 68.95907`, > 62.013`, 64.10658`, 66.00879`, 65.77796`, 66.94446`, 66.81229`, > 67.01431`, 67.43705`, 66.8442`, 67.25391`, 67.52273`, 67.17782`, > 67.6068`, 66.8991`, 66.74675`, 67.16928`, 67.23833`, 66.75589`, > 66.79828`, 67.488`, 67.1104`, 67.06455`, 66.93899`, 67.54723`, > 66.85662`, 67.70971`, 67.88296`, 68.66534`, 68.58164`, 68.44493`, > 68.41199`, 68.44665`, 68.38258`, 67.92987`, 68.3033`, 67.97479`, > 68.18304`, 68.57984`, 68.56974`, 67.81854`, 67.8796`, 68.22794`, > 68.01258`, 67.85023`, 67.80077`, 68.59968`, 68.08671`, 67.87656`, > 68.47849`, 68.60006`, 68.07838`, 68.08199`, 67.73211`, 68.4132`, > 68.59541`, 68.28458`, 68.06489`, 68.41445`, 69.36998`, 69.00435`, > 69.37297`, 68.89496`, 69.37382`, 69.34415`, 68.96686`, 69.59887`, > 69.24597`, 69.68301`, 68.90541`, 69.07283`, 69.03297`, 69.18202`, > 69.64233`, 68.82818`, 69.24165`, 69.10265`, 68.98512`, 69.31551`, > 69.20435`, 68.93765`, 69.36661`, 68.71181`, 68.75662`, 69.35439`, > 69.74222`, 69.82326`, 69.90223`, 70.2992`, 69.83745`, 69.94847`, > 70.27479`, 70.67752`, 70.38903`, 70.37578`, 70.60668`, 70.16921`, > 69.85223`, 70.23353`, 70.28373`, 70.33881`, 69.81443`, 70.54739`, > 69.96746`, 69.73702`, 69.8604`, 70.87111`, 71.36657`, 71.1878`, > 70.75001`, 70.72998`, 71.32092`, 70.88794`, 70.9085`, 70.87662`, > 71.19803`, 71.31925`, 71.22916`, 71.35939`, 71.60205`, 70.97309`, > 71.1886`, 71.40319`, 71.39524`, 70.88752`, 71.27449`, 72.10289`, > 72.03197`, 71.9969`, 71.72577`, 71.92914`, 72.20518`, 72.29401`, > 72.5854`, 72.04673`, 71.80541`, 71.80464`, 73.06559`, 73.44548`, > 73.19223`, 73.37471`, 73.22554`, 72.88357`, 72.77826`, 73.26989`, > 73.96165`, 74.64342`, 73.92565`, 74.58767`, 74.31029`, 75.10003`, > 77.15504`, 60.78204`, 62.36303`, 66.40186`, 58.50708`, 70.00052`, > 70.99433`, 64.96417`, 70.47639`, 69.23383`, 64.90184`, 68.7749`, > 69.85805`, 62.52373`, 63.28805`, 63.52861`, 62.87456`, 63.91754`, > 64.32325`, 64.22405`, 64.59643`, 64.28548`, 63.78835`, 65.66404`, > 64.80838`, 65.63528`, 64.74897`, 64.79081`, 65.10988`, 65.55215`, > 65.30083`, 65.1426`, 65.09433`, 64.81397`, 65.95058`, 66.37511`, > 66.38624`, 66.31904`, 65.80919`, 66.09556`, 66.49077`, 66.32632`, > 66.59779`, 66.00909`, 66.45585`, 66.00818`, 66.46605`, 66.37783`, > 66.34685`, 66.31558`, 66.62303`, 66.79229`, 67.5336`, 67.15587`, > 66.78051`, 67.25544`, 66.79006`, 66.88298`, 68.1121`, 63.61572`, > 63.17978`, 65.67211`, 67.23403`, 67.4089`, 67.57913`, 67.20643`, > 67.10018`, 66.80557`, 67.09308`, 66.91372`, 66.77528`, 66.97572`, > 67.66639`, 67.62089`, 67.66841`, 67.32572`, 67.04153`, 66.96445`, > 67.07223`, 67.169`, 67.48077`, 67.67057`, 66.86465`, 67.04437`, > 67.72523`, 68.52969`, 67.8741`, 67.84693`, 68.26632`, 68.18364`, > 68.55723`, 67.77137`, 67.92976`, 67.72522`, 67.98916`, 68.0679`, > 67.772`, 68.11035`, 68.16623`, 68.61054`, 68.2893`, 68.38263`, > 68.6212`, 68.27802`, 67.93914`, 67.7105`, 68.351`, 68.14712`, > 67.97421`, 68.23682`, 68.05699`, 68.49856`, 68.58894`, 67.74098`, > 68.69765`, 68.63531`, 68.37844`, 69.11352`, 69.35385`, 69.5135`, > 69.11`, 69.64324`, 69.40655`, 69.18575`, 68.80709`, 69.11679`, > 69.02706`, 69.05703`, 69.14581`, 68.7308`, 68.9798`, 68.95303`, > 69.1639`, 68.81649`, 68.73746`, 69.00102`, 69.28222`, 69.37676`, > 68.90879`, 69.32318`, 69.63872`, 69.43581`, 68.97885`, 69.54252`, > 68.73497`, 69.20127`, 70.36167`, 70.10118`, 70.39507`, 70.03877`, > 69.76556`, 70.39131`, 70.0372`, 70.25908`, 69.87081`, 70.69845`, > 70.25756`, 69.7177`, 70.31993`, 69.95735`, 69.72691`, 70.22698`, > 70.02038`, 70.32035`, 70.39947`, 69.78074`, 69.7598`, 70.53827`, > 70.03449`, 70.59135`, 71.13378`, 71.15371`, 71.03018`, 70.93936`, > 70.78603`, 71.50695`, 71.57023`, 70.83563`, 70.96118`, 71.55428`, > 71.08274`, 71.49587`, 71.36997`, 71.49891`, 71.01177`, 71.62784`, > 71.36701`, 71.23426`, 70.90129`, 71.53087`, 72.441`, 72.5999`, > 71.79167`, 72.00806`, 72.01746`, 72.44981`, 71.92864`, 72.0908`, > 72.57398`, 72.53335`, 71.78483`, 72.57594`, 73.06795`, 73.18852`, > 73.39371`, 73.3754`, 73.67679`, 72.84789`, 72.99608`, 74.67822`, > 73.8507`, 74.35692`, 73.99906`, 73.92525`, 75.67784`, 76.10484`, > 78.2476`, 61.89619`, 69.86215`, 62.26801`, 71.40839`, 71.60925`, > 65.51351`, 71.86574`, 71.16645`, 64.53321`, 65.25053`, 69.62871`, > 65.10223`, 61.03526`, 63.12132`, 63.5968`, 63.47848`, 63.83162`, > 64.18388`, 64.66888`, 64.06363`, 64.38072`, 64.60295`, 64.81735`, > 65.22864`, 65.62354`, 65.62755`, 64.8584`, 65.6482`, 65.6904`, > 65.58218`, 65.08945`, 64.87234`, 65.68794`, 66.54461`, 66.23255`, > 65.91034`, 66.29882`, 66.33603`, 66.19024`, 66.12728`, 66.1938`, > 65.82389`, 66.61389`, 66.45299`, 66.25633`, 66.53703`, 66.28457`, > 65.90354`, 66.61969`, 66.59349`, 67.30641`, 67.41523`, 67.51658`, > 66.94071`, 67.11246`, 66.99107`, 66.94124`, 68.06898`, 67.47908`, > 63.00731`, 67.40208`, 68.75691`, 66.90827`, 67.28305`, 67.15978`, > 67.12405`, 67.07313`, 67.17665`, 66.74724`, 66.81865`, 67.43735`, > 67.37322`, 66.96049`, 67.40154`, 66.91834`, 66.93007`, 66.78425`, > 66.7842`, 67.15158`, 67.45025`, 67.68985`, 67.13767`, 67.60589`, > 67.96334`, 68.65674`, 68.42972`, 68.01111`, 68.61891`, 68.50647`, > 67.77439`, 68.09837`, 68.19228`, 68.54918`, 68.59413`, 68.65282`, > 68.40294`, 68.54259`, 68.59444`, 67.87885`, 68.0454`, 67.96346`, > 68.55092`, 68.07785`, 67.93252`, 68.5916`, 67.90891`, 68.63842`, > 68.6514`, 68.40634`, 68.19563`, 68.3391`, 68.13175`, 67.79551`, > 68.24471`, 67.96366`, 68.02669`, 68.07695`, 69.23339`, 69.22874`, > 68.9062`, 69.33247`, 69.53206`, 69.02418`, 69.26288`, 69.55433`, > 69.3664`, 68.96569`, 69.33038`, 69.10425`, 69.29199`, 69.26009`, > 68.71424`, 69.48488`, 69.48141`, 68.88311`, 68.83524`, 69.42378`, > 68.82387`, 69.06951`, 69.18528`, 69.26989`, 68.83727`, 69.11594`, > 69.39569`, 68.70258`, 70.39288`, 70.49606`, 70.11817`, 69.75304`, > 70.25238`, 70.28837`, 69.71807`, 70.13835`, 70.41752`, 69.91638`, > 69.7803`, 69.90789`, 70.29221`, 70.20136`, 70.42766`, 70.40239`, > 70.65713`, 69.7276`, 70.45174`, 70.52536`, 70.45682`, 70.52011`, > 70.25621`, 70.32714`, 71.39933`, 71.03487`, 71.61276`, 70.90129`, > 71.36831`, 71.46158`, 71.22939`, 71.59368`, 71.6476`, 71.33885`, > 71.13133`, 71.52388`, 70.95837`, 71.48199`, 70.85433`, 71.41922`, > 71.30872`, 71.22321`, 71.4506`, 70.76122`, 72.65576`, 71.96434`, > 72.3071`, 72.2446`, 72.38029`, 72.04211`, 71.77644`, 72.54877`, > 72.57381`, 71.90584`, 72.62022`, 72.4218`, 73.13823`, 73.60773`, > 73.2649`, 73.0769`, 73.69792`, 73.60551`, 72.87015`, 73.90142`, > 74.32431`, 73.87776`, 74.20972`, 74.47833`, 75.07304`, 76.3516`, > 78.36479`, 61.22021`, 72.63356`, 64.94291`, 73.02984`, 71.81569`, > 65.29123`, 60.90911`, 72.131`, 70.98853`, 61.7019`, 67.51436`, > 64.37789`, 63.2825`, 63.47892`, 63.66235`, 63.94637`, 63.93831`, > 63.94722`, 64.08187`, 64.68702`, 64.38337`, 63.91132`, 64.84282`, > 65.33216`, 65.2375`, 65.47348`, 65.16309`, 65.35727`, 65.59545`, > 64.70258`, 64.76966`, 65.55892`, 65.42338`, 66.54624`, 65.70133`, > 66.12315`, 66.2678`, 66.55539`, 66.42398`, 66.50633`, 66.27712`, > 66.42142`, 66.25827`, 66.1285`, 66.53558`, 66.32575`, 66.11991`, > 65.87925`, 65.70978`, 66.10198`, 67.57237`, 67.4361`, 67.00761`, > 67.21048`, 67.1921`, 67.39528`, 67.44979`, 68.18883`, 62.74094`, > 66.34954`, 65.69966`, 68.36264`, 67.52548`, 67.24632`, 67.21519`, > 67.45383`, 66.93472`, 67.6832`, 66.97218`, 66.73049`, 66.75153`, > 67.4346`, 66.92896`, 67.49282`, 66.93944`, 67.03135`, 66.91542`, > 66.97758`, 67.14932`, 67.53093`, 67.52202`, 67.27928`, 67.56893`, > 67.75773`, 68.10565`, 68.49664`, 68.5851`, 67.85579`, 68.60796`, > 68.19156`, 68.25828`, 68.15401`, 68.18623`, 68.16064`, 68.6097`, > 68.34391`, 68.65678`, 68.51914`, 67.72093`, 67.96986`, 67.75073`, > 68.09745`, 68.64602`, 68.2318`, 68.18244`, 68.15011`, 68.13611`, > 68.10048`, 68.53037`, 68.37728`, 68.17652`, 67.7452`, 67.93037`, > 68.25872`, 68.33639`, 68.27405`, 69.5816`, 68.70027`, 68.93075`, > 68.78663`, 69.0649`, 68.99285`, 68.99516`, 68.73929`, 69.47357`, > 69.08392`, 69.07281`, 69.62286`, 69.35683`, 69.16149`, 68.81413`, > 68.9529`, 69.47561`, 69.5506`, 69.38889`, 69.57241`, 69.37092`, > 68.92229`, 68.71081`, 69.2671`, 68.74473`, 68.81509`, 69.47472`, > 69.69307`, 69.65334`, 70.46902`, 70.00607`, 70.61711`, 70.51318`, > 69.97204`, 69.92313`, 70.46938`, 69.91923`, 69.71908`, 70.61155`, > 70.20868`, 70.27586`, 70.18348`, 70.5115`, 70.50015`, 70.24017`, > 70.001`, 70.21726`, 70.20554`, 69.97788`, 70.36632`, 70.38931`, > 70.18593`, 70.23168`, 70.74197`, 71.47899`, 71.41695`, 71.20207`, > 70.87987`, 71.26557`, 71.41653`, 71.24074`, 71.15528`, 71.20588`, > 70.98515`, 71.35642`, 71.21331`, 71.59639`, 71.25854`, 71.53325`, > 70.92787`, 71.54787`, 71.07293`, 70.86163`, 72.67319`, 71.77245`, > 72.64278`, 72.48159`, 71.9078`, 72.18324`, 72.55104`, 72.33861`, > 72.07098`, 72.30647`, 72.05185`, 72.75204`, 72.79178`, 73.50606`, > 73.68578`, 72.79593`, 73.41049`, 73.02077`, 73.20758`, 74.49237`, > 73.81263`, 73.81376`, 73.82642`, 73.81739`, 75.57544`, 77.23474`, > 60.05859`, 76.81927`, 66.72684`, 58.79456`, 67.89277`, 61.04946`, > 59.81693`, 70.75232`, 68.26774`, 69.30589`, 69.30199`, 67.015`}; > > In[60]:= lm = LinearModelFit[GaltonDat, {1, x}, x] > > Out[60]= FittedModel[\\!\\(\\* > PanelBox[ > TagBox[ > RowBox[{\33.88660435407788`\, \ \, \+\, > RowBox[{\0.5140930386233082`\, \ \, \x\}]}], > Short], > FrameMargins->5]\\)] > > In[62]:= lm[\BestFit\] > > Out[62]= 33.8866 + 0.514093 x > > In[63]:= r2 = Correlation[GaltonX, GaltonY] > > Out[63]= 0.501338 > === Subject: Re: Difference Fit vs. Correlation The slope of the regression line will equal the correlation only when the two standard deviations equal one another. Dimensions[XY = Transpose@{X,Y}] {1078,2} f = Fit[XY,{1,x},x] a = f[[1]] b = f[[2,1]] 33.8866 + 0.514093 x 33.8866 0.514093 {mx,my} = Mean@XY {sx,sy} = StandardDeviation@XY r = Correlation[X,Y] {67.6871,68.6841} {2.74487,2.8147} 0.501338 b == r*sy/sx True a == my - b*mx True > in the code below, using Correlation I get 0.501338, using Fit I get > 0.514093. > How come? > > Claus > > In[47]:= GaltonX = {65.04851`, 63.25094`, 64.95532`, 65.7525`, > 61.13723`, 63.02254`, 65.37053`, 64.72398`, 66.06509`, 66.96738`, > 59.008`, 62.93203`, 63.67063`, 64.07386`, 64.68851`, 65.15466`, > 66.37353`, 65.57704`, 67.36765`, 66.75929`, 67.79764`, 69.5348`, > 62.54014`, 63.81016`, 64.4565`, 64.9665`, 64.70662`, 65.73829`, > 65.50141`, 65.55416`, 66.90294`, 66.57388`, 66.53198`, 67.90613`, > 68.29198`, 67.74123`, 68.46917`, 69.38327`, 71.81791`, 62.41615`, > 64.49083`, 64.4876`, 63.92303`, 65.44592`, 65.02977`, 65.67038`, > 68.66078`, 66.54597`, 64.85954`, 69.60692`, 64.8135`, 65.32703`, > 65.83169`, 65.83427`, 65.56135`, 65.8688`, 65.77339`, 67.09116`, > 66.61374`, 67.41075`, 67.27716`, 66.61134`, 68.17412`, 67.80555`, > 68.32529`, 68.07787`, 68.96795`, 68.9255`, 69.60862`, 70.35646`, > 70.00643`, 72.75425`, 62.82147`, 62.86855`, 63.91261`, 64.54118`, > 64.51906`, 66.02688`, 65.81011`, 66.01812`, 65.53742`, 65.73346`, > 66.77424`, 66.67869`, 66.97585`, 66.94021`, 66.84575`, 67.12008`, > 67.74181`, 68.27194`, 67.60691`, 68.44737`, 67.65832`, 68.71193`, > 69.32025`, 68.7403`, 69.13395`, 69.34995`, 68.6297`, 69.58258`, > 70.39517`, 71.19284`, 70.82429`, 71.65367`, 73.28133`, 63.03753`, > 63.66428`, 65.38311`, 64.60205`, 66.40661`, 65.76985`, 65.66729`, > 66.05712`, 66.54635`, 66.5723`, 66.64876`, 67.71899`, 68.48726`, > 67.82769`, 67.55801`, 68.07763`, 69.16715`, 68.693`, 68.61779`, > 68.64797`, 68.61666`, 70.36485`, 70.0099`, 70.13984`, 70.2073`, > 71.28063`, 70.90445`, 72.19036`, 74.96203`, 64.88218`, 65.55174`, > 65.65889`, 65.92826`, 65.94198`, 67.43646`, 67.48444`, 67.61344`, > 68.4518`, 68.49456`, 68.1056`, 69.48308`, 69.07389`, 69.39251`, > 69.44294`, 69.52131`, 70.15463`, 69.86911`, 70.44394`, 70.85393`, > 71.30074`, 72.13978`, 72.19045`, 75.43393`, 64.51788`, 66.36335`, > 65.56855`, 66.78957`, 66.91193`, 68.1714`, 67.50102`, 67.83492`, > 68.95255`, 69.26`, 68.74223`, 69.74288`, 70.29942`, 70.04402`, > 70.23559`, 70.88075`, 71.19091`, 72.37396`, 73.03345`, 74.8083`, > 67.39521`, 67.31523`, 67.77952`, 69.33827`, 68.72404`, 69.98991`, > 69.75383`, 70.65942`, 71.10882`, 72.4811`, 72.4801`, 67.52214`, > 68.23931`, 68.7997`, 69.89568`, 71.48641`, 70.76482`, 71.9137`, > 63.08399`, 68.23241`, 70.05787`, 70.83996`, 72.56944`, 67.93353`, > 67.54033`, 72.79855`, 62.67482`, 68.19196`, 65.07215`, 73.42952`, > 62.94125`, 62.53667`, 69.90248`, 71.07217`, 71.11059`, 69.48402`, > 70.18338`, 65.46124`, 62.04073`, 63.60063`, 65.60613`, 68.02969`, > 61.81571`, 63.78886`, 64.89023`, 65.79072`, 66.42371`, 68.80877`, > 61.76521`, 64.30302`, 63.69064`, 64.99662`, 65.34899`, 64.81278`, > 65.71736`, 66.03148`, 67.04912`, 67.77522`, 69.04964`, 62.1833`, > 62.76393`, 63.88391`, 65.41055`, 64.62347`, 65.64621`, 66.16257`, > 65.99538`, 65.79786`, 67.42936`, 67.11933`, 67.32907`, 67.86233`, > 68.31609`, 67.96359`, 68.68615`, 71.18085`, 62.4296`, 62.88524`, > 64.07313`, 63.88597`, 64.8272`, 65.39653`, 64.77344`, 68.66581`, > 65.19783`, 64.32621`, 66.08278`, 69.01679`, 64.50194`, 66.07654`, > 65.73631`, 66.45485`, 65.63018`, 66.39423`, 67.33687`, 66.83938`, > 66.69739`, 67.34708`, 67.35319`, 67.93575`, 67.76608`, 68.11569`, > 68.2548`, 68.83427`, 69.40758`, 69.32068`, 70.48`, 70.06429`, > 70.63764`, 62.41134`, 63.15274`, 63.51409`, 63.91446`, 64.61683`, > 64.86185`, 65.91332`, 66.1992`, 66.45978`, 65.50286`, 66.87795`, > 67.0791`, 66.83256`, 67.18231`, 66.51763`, 66.95295`, 66.63586`, > 68.18453`, 67.60565`, 68.27918`, 67.97994`, 69.00094`, 69.31139`, > 68.88641`, 68.94824`, 69.42186`, 69.49516`, 70.34647`, 69.92358`, > 70.69078`, 70.56571`, 72.40997`, 72.47685`, 62.72118`, 63.9001`, > 64.50433`, 64.81813`, 65.37582`, 65.82612`, 66.29436`, 65.81042`, > 66.80854`, 67.16724`, 67.30525`, 67.54577`, 67.86855`, 68.35003`, > 67.60818`, 68.48397`, 68.56724`, 69.07405`, 68.56831`, 69.15373`, > 68.60744`, 68.5443`, 69.65536`, 70.41632`, 69.97528`, 70.26613`, > 71.31667`, 71.29178`, 72.59442`, 64.40268`, 64.9127`, 66.34756`, > 66.04291`, 65.69477`, 66.71512`, 66.64971`, 68.33241`, 67.94335`, > 67.96734`, 68.27657`, 68.75008`, 69.05441`, 69.00755`, 69.39488`, > 69.7628`, 69.6464`, 70.45427`, 69.89852`, 70.984`, 71.22015`, > 71.45442`, 71.60966`, 73.20296`, 63.89132`, 65.99384`, 66.0424`, > 67.47658`, 66.68527`, 68.27034`, 67.72898`, 68.28372`, 68.39453`, > 69.12925`, 69.10844`, 69.74196`, 69.9987`, 69.56148`, 69.97779`, > 70.88691`, 70.64687`, 72.26404`, 71.50569`, 73.01402`, 66.20254`, > 67.26312`, 67.8086`, 69.08284`, 69.35107`, 69.59962`, 70.08948`, > 70.18385`, 71.26955`, 72.07717`, 72.33894`, 67.06776`, 67.85929`, > 69.07274`, 69.59893`, 69.73728`, 70.54066`, 72.40962`, 72.78889`, > 68.10144`, 68.6106`, 71.293`, 72.09445`, 74.69236`, 71.16246`, > 68.30804`, 60.41857`, 63.94459`, 63.06849`, 63.98036`, 73.89524`, > 72.03687`, 61.02471`, 65.39914`, 71.96564`, 71.29643`, 65.15837`, > 68.90263`, 64.45192`, 63.99469`, 66.46124`, 67.12556`, 62.27941`, > 63.8488`, 65.43612`, 65.62145`, 66.16956`, 67.62675`, 60.21393`, > 62.99378`, 63.57239`, 65.15088`, 65.13462`, 64.79732`, 66.24856`, > 66.22743`, 66.6056`, 67.99167`, 69.04862`, 62.12902`, 63.16227`, > 64.45497`, 63.75483`, 64.63959`, 64.59106`, 66.06003`, 65.98544`, > 65.66176`, 67.11501`, 67.31302`, 67.16149`, 68.38679`, 67.64175`, > 67.55466`, 68.53614`, 70.02702`, 61.07412`, 62.72387`, 64.28642`, > 64.11073`, 63.68318`, 64.68393`, 64.66753`, 67.95848`, 64.60933`, > 66.07775`, 65.25267`, 69.67201`, 65.33965`, 65.54375`, 66.1112`, > 66.22968`, 66.00879`, 66.03248`, 65.94624`, 67.09734`, 66.98893`, > 67.38837`, 67.4075`, 67.31108`, 68.27151`, 68.33586`, 67.56752`, > 68.23182`, 69.07604`, 68.77033`, 70.49154`, 70.00767`, 69.52007`, > 61.50617`, 62.93875`, 64.10318`, 63.85157`, 65.08731`, 64.62588`, > 65.8912`, 66.24386`, 65.66031`, 66.05344`, 66.30711`, 67.15303`, > 66.90986`, 66.89436`, 66.56566`, 67.23789`, 67.05684`, 67.94515`, > 67.94026`, 67.84234`, 67.91887`, 68.63961`, 68.60477`, 69.04036`, > 69.03336`, 69.12497`, 68.53779`, 70.24335`, 69.84308`, 69.90057`, > 71.48946`, 72.37013`, 71.94413`, 61.01904`, 63.0108`, 64.5793`, > 65.39658`, 64.84995`, 65.54542`, 65.56421`, 66.09747`, 67.40602`, > 66.5839`, 67.41035`, 67.21634`, 68.23175`, 67.88053`, 68.0153`, > 67.69332`, 68.85462`, 68.73264`, 69.0711`, 68.79964`, 68.79876`, > 69.32241`, 69.60923`, 69.76071`, 70.1611`, 70.12109`, 71.10802`, > 71.44164`, 71.75006`, 64.35591`, 65.16253`, 66.09529`, 65.78674`, > 65.53927`, 66.71703`, 67.17284`, 67.16853`, 68.06061`, 67.85988`, > 68.1968`, 69.29537`, 68.84067`, 69.18095`, 68.69659`, 69.45833`, > 70.0483`, 69.6916`, 70.20658`, 70.79086`, 70.87977`, 71.30702`, > 72.3266`, 72.7824`, 64.40052`, 64.89121`, 65.84506`, 67.35461`, > 67.44953`, 67.86439`, 67.92443`, 68.49998`, 67.60602`, 69.37288`, > 69.34931`, 69.48306`, 70.21887`, 70.02161`, 69.83698`, 69.6041`, > 71.49829`, 72.16894`, 72.41045`, 72.52521`, 64.6702`, 66.78417`, > 67.83401`, 68.15907`, 69.19301`, 68.86739`, 70.11126`, 70.12007`, > 71.03691`, 71.43196`, 72.04564`, 72.738`, 68.02564`, 69.04939`, > 68.86356`, 69.63421`, 71.24085`, 71.95679`, 72.89983`, 65.86028`, > 68.48883`, 70.72676`, 72.34582`, 72.59922`, 68.82986`, 73.49987`, > 70.0599`, 67.9291`, 64.66998`, 60.7795`, 74.94058`, 70.64925`, > 60.91526`, 65.28934`, 71.362`, 71.66893`, 62.68868`, 71.39326`, > 66.56302`, 67.18788`, 62.532`, 64.85512`, 66.94161`, 62.3603`, > 63.58145`, 65.44633`, 65.00539`, 66.43717`, 66.6676`, 59.4898`, > 63.00108`, 64.0892`, 64.0753`, 64.52103`, 65.19231`, 66.30604`, > 66.03081`, 66.83096`, 68.19724`, 68.6599`, 61.29369`, 63.26089`, > 63.86162`, 64.13176`, 64.81105`, 64.55987`, 66.19437`, 66.5`, > 66.43436`, 67.30468`, 67.36559`, 67.29162`, 67.69874`, 68.38221`, > 67.76712`, 69.29587`, 69.66477`, 60.03436`, 62.1356`, 63.64047`, > 63.82278`, 64.46555`, 64.73798`, 65.43021`, 65.07381`, 69.29517`, > 67.67996`, 64.94267`, 69.47933`, 65.05963`, 65.01253`, 65.61963`, > 65.94819`, 65.68803`, 65.87689`, 65.91481`, 67.41946`, 66.53833`, > 67.41995`, 67.21977`, 67.33721`, 68.11283`, 68.02017`, 68.02829`, > 68.35139`, 68.80254`, 69.49307`, 70.2297`, 69.71997`, 70.16651`, > 61.07369`, 62.66947`, 64.32254`, 64.27362`, 64.96148`, 64.77222`, > 66.2365`, 66.10686`, 66.42772`, 66.22727`, 65.87574`, 67.03017`, > 67.48545`, 66.7367`, 66.69181`, 67.31766`, 67.1219`, 67.82592`, > 68.4376`, 67.74551`, 68.0934`, 67.71665`, 68.99349`, 69.24616`, > 69.2828`, 69.26254`, 68.75605`, 69.62519`, 69.61942`, 69.94715`, > 70.58916`, 72.34058`, 71.56142`, 72.94457`, 63.33777`, 64.3445`, > 65.14077`, 65.2424`, 65.90397`, 65.98763`, 65.57065`, 65.82733`, > 66.88576`, 66.98594`, 67.41537`, 67.93319`, 67.77812`, 68.44999`, > 68.32281`, 68.35148`, 68.73678`, 68.97673`, 69.31931`, 68.80442`, > 68.90434`, 69.80381`, 69.66712`, 70.38052`, 70.29892`, 71.02634`, > 71.28432`, 72.03259`, 63.26539`, 64.87623`, 65.72722`, 66.13831`, > 66.48902`, 66.06395`, 66.73532`, 67.12329`, 67.57161`, 68.18286`, > 68.33868`, 68.14658`, 69.17022`, 69.17597`, 68.52789`, 68.84874`, > 69.69833`, 69.86528`, 70.48646`, 71.16238`, 70.58946`, 70.54353`, > 72.38576`, 73.18522`, 64.12344`, 64.62855`, 65.74244`, 67.11563`, > 66.81497`, 68.38001`, 68.33835`, 68.25066`, 68.36488`, 68.67873`, > 68.70293`, 69.0466`, 70.17375`, 69.86849`, 70.15821`, 70.24204`, > 71.41811`, 70.66031`, 72.42614`, 73.04341`, 64.6891`, 67.09928`, > 67.79858`, 68.37299`, 69.19364`, 68.5938`, 69.86969`, 70.17952`, > 70.51811`, 71.00743`, 71.83086`, 72.81121`, 67.95451`, 67.81317`, > 69.32812`, 70.45127`, 71.38916`, 72.31022`, 71.8821`, 64.61601`, > 67.75382`, 69.90335`, 70.87039`, 72.71533`, 69.03942`, 72.44463`, > 69.07253`, 70.1758`, 72.37219`, 59.63777`, 73.27737`, 68.12621`, > 63.15234`, 66.00489`, 71.45303`, 68.1456`, 65.25527`, 70.41584`, > 68.38452`, 61.89133`, 64.98391`, 66.21887`, 59.48391`, 62.77645`, > 63.86507`, 64.56486`, 65.60265`, 66.28333`, 70.55256`, 62.14539`, > 64.37906`, 64.35191`, 64.91304`, 65.33085`, 65.17545`, 66.10285`, > 66.05004`, 67.38231`, 67.83999`, 70.27309`, 63.19263`, 63.66834`, > 64.12671`, 64.71388`, 65.14662`, 65.94428`, 65.67785`, 65.95134`, > 67.30819`, 66.69404`, 66.56885`, 66.80951`, 68.24011`, 67.5344`, > 68.4157`, 69.09588`, 70.81036`, 61.68183`, 63.04493`, 64.34945`, > 63.89336`, 65.48176`, 64.726`, 64.65128`, 67.47271`, 66.76701`, > 64.98147`, 69.38684`, 63.7123`, 64.63358`, 66.00037`, 65.96621`, > 66.49751`, 66.27177`, 65.67892`, 66.86814`, 66.73495`, 66.53357`, > 67.05051`, 67.04958`, 67.55908`, 67.58076`, 67.51942`, 68.12592`, > 68.57465`, 68.52484`, 69.20286`, 69.7551`, 69.91868`, 70.50329`, > 62.83528`, 63.24504`, 64.44602`, 64.31819`, 64.73521`, 64.72352`, > 65.97741`, 65.63739`, 65.83449`, 65.87064`, 66.61001`, 66.75821`, > 66.77012`, 67.21373`, 67.09047`, 66.93359`, 68.03852`, 67.98476`, > 68.25046`, 68.26078`, 68.21235`, 68.54029`, 68.50469`, 69.13248`, > 69.21981`, 69.34385`, 69.41153`, 70.25056`, 69.68641`, 70.51091`, > 71.29598`, 72.20218`, 72.33929`, 62.91628`, 63.93525`, 64.59851`, > 65.47401`, 65.864`, 66.30684`, 65.77587`, 66.48386`, 67.31983`, > 67.39901`, 67.05939`, 68.45161`, 67.7061`, 68.08389`, 67.58923`, > 67.80388`, 69.25919`, 69.05302`, 68.70921`, 69.02788`, 68.94943`, > 68.81536`, 69.91801`, 70.45072`, 69.96349`, 69.75787`, 71.38281`, > 71.08122`, 72.74936`, 65.26855`, 66.01549`, 65.5142`, 65.62374`, > 65.92199`, 67.11129`, 66.89727`, 67.94195`, 67.7274`, 67.54999`, > 67.96013`, 68.83038`, 69.43917`, 68.55957`, 69.10638`, 70.4814`, > 69.92992`, 70.04238`, 69.56779`, 71.01077`, 70.62603`, 71.46383`, > 71.62112`, 73.87758`, 65.00573`, 66.30354`, 65.86743`, 66.86667`, > 67.15958`, 68.06904`, 67.57382`, 67.63354`, 69.41356`, 68.87192`, > 69.07779`, 69.81177`, 70.01463`, 69.56649`, 70.254`, 70.68296`, > 70.87874`, 72.45099`, 73.04359`, 74.40915`, 67.40139`, 66.53122`, > 68.04593`, 68.82772`, 69.33069`, 70.34676`, 70.173`, 70.80883`, > 70.7029`, 72.35959`, 72.3661`, 67.17534`, 67.84045`, 68.9053`, > 70.3752`, 71.18523`, 71.41254`, 71.70673`, 72.60072`, 67.57652`, > 68.55814`, 70.95019`, 71.99783`, 75.17469`, 73.07157`, 69.92407`, > 65.54323`, 72.56261`, 72.15051`, 63.22006`, 73.2645`, 65.81296`, > 67.70657`, 66.99681`, 71.33181`, 71.78314`, 70.73837`, 70.30609`}; > > In[59]:= GaltonY = {59.77827`, 63.21404`, 63.34242`, 62.79238`, > 64.28113`, 64.24221`, 64.08231`, 63.99574`, 64.61338`, 63.97944`, > 65.24451`, 65.35102`, 65.67992`, 65.43664`, 65.29391`, 64.79017`, > 65.01881`, 65.5464`, 65.08145`, 65.49008`, 65.1352`, 65.51262`, > 66.58436`, 66.37842`, 66.14782`, 65.97259`, 65.95887`, 66.45202`, > 65.74797`, 65.97164`, 65.90548`, 65.90773`, 66.47103`, 65.75023`, > 66.34666`, 66.08577`, 66.28037`, 66.34354`, 66.41711`, 67.22558`, > 67.46394`, 66.99362`, 66.76647`, 67.0342`, 66.84316`, 69.2989`, > 69.09114`, 61.66358`, 65.7288`, 68.98012`, 67.37397`, 67.17459`, > 67.06712`, 67.29446`, 67.62665`, 67.47923`, 66.92162`, 67.58324`, > 67.21191`, 66.81629`, 67.24268`, 67.51036`, 67.57026`, 67.17258`, > 67.54129`, 67.37113`, 67.59714`, 67.25104`, 66.82533`, 66.72679`, > 66.92996`, 67.64847`, 68.04291`, 68.4885`, 68.04777`, 68.34573`, > 68.33829`, 68.3138`, 68.18333`, 68.51056`, 68.12014`, 68.31563`, > 68.04774`, 68.61273`, 67.9425`, 68.08381`, 68.36754`, 67.85181`, > 68.19806`, 68.01897`, 68.23431`, 67.89742`, 68.62409`, 67.97912`, > 68.2668`, 67.94192`, 68.62072`, 68.23857`, 68.58554`, 68.06568`, > 68.38188`, 67.75943`, 68.59991`, 67.91483`, 67.83861`, 68.77562`, > 69.60782`, 69.69143`, 69.41491`, 69.68931`, 69.20775`, 69.45627`, > 69.59614`, 69.27994`, 69.52338`, 68.74406`, 69.30987`, 69.22571`, > 69.24073`, 69.4912`, 69.11921`, 68.93751`, 69.45774`, 69.27599`, > 69.22869`, 68.70547`, 69.34638`, 68.87137`, 69.30262`, 69.1579`, > 69.62727`, 69.11014`, 69.09596`, 69.03281`, 69.85677`, 70.06274`, > 69.89765`, 70.26185`, 70.52663`, 70.52744`, 69.7865`, 70.36684`, > 69.97604`, 69.83308`, 70.69951`, 70.16871`, 70.11632`, 69.95433`, > 70.31279`, 69.80903`, 69.96792`, 69.93939`, 69.73486`, 70.08397`, > 70.01015`, 70.65025`, 70.01253`, 70.09077`, 71.34319`, 70.81542`, > 71.44929`, 71.18676`, 71.66276`, 71.39516`, 70.73612`, 71.2608`, > 71.04721`, 71.2592`, 70.89486`, 71.31732`, 71.55712`, 71.17701`, > 71.03412`, 71.37275`, 71.64741`, 71.1205`, 70.91756`, 71.66455`, > 72.39198`, 71.87928`, 72.34482`, 72.17265`, 72.52078`, 71.98836`, > 72.34482`, 72.45347`, 72.26945`, 71.96844`, 72.18169`, 72.7864`, > 73.0414`, 72.87858`, 73.17304`, 73.63274`, 72.88245`, 73.18148`, > 74.3209`, 74.40727`, 73.76791`, 73.92119`, 73.75503`, 75.56214`, > 75.70222`, 77.21338`, 61.28882`, 74.28343`, 70.93102`, 75.34802`, > 61.78758`, 64.00009`, 62.4658`, 73.70465`, 66.3495`, 62.20543`, > 65.421`, 63.9922`, 62.78458`, 63.52486`, 63.49966`, 62.89658`, > 63.72784`, 63.73231`, 64.39579`, 63.70072`, 64.44796`, 64.2795`, > 65.18412`, 65.10118`, 65.56277`, 64.94454`, 65.14227`, 65.16843`, > 65.58149`, 65.63474`, 64.87191`, 65.4176`, 64.7231`, 65.84559`, > 65.77333`, 66.67371`, 66.54726`, 66.43228`, 66.3326`, 66.24935`, > 66.39759`, 66.69366`, 66.22114`, 66.43499`, 66.65758`, 65.76873`, > 66.20784`, 66.30166`, 65.81894`, 66.34562`, 66.88369`, 66.8162`, > 67.36245`, 67.68308`, 67.19885`, 67.26903`, 67.45131`, 68.95907`, > 62.013`, 64.10658`, 66.00879`, 65.77796`, 66.94446`, 66.81229`, > 67.01431`, 67.43705`, 66.8442`, 67.25391`, 67.52273`, 67.17782`, > 67.6068`, 66.8991`, 66.74675`, 67.16928`, 67.23833`, 66.75589`, > 66.79828`, 67.488`, 67.1104`, 67.06455`, 66.93899`, 67.54723`, > 66.85662`, 67.70971`, 67.88296`, 68.66534`, 68.58164`, 68.44493`, > 68.41199`, 68.44665`, 68.38258`, 67.92987`, 68.3033`, 67.97479`, > 68.18304`, 68.57984`, 68.56974`, 67.81854`, 67.8796`, 68.22794`, > 68.01258`, 67.85023`, 67.80077`, 68.59968`, 68.08671`, 67.87656`, > 68.47849`, 68.60006`, 68.07838`, 68.08199`, 67.73211`, 68.4132`, > 68.59541`, 68.28458`, 68.06489`, 68.41445`, 69.36998`, 69.00435`, > 69.37297`, 68.89496`, 69.37382`, 69.34415`, 68.96686`, 69.59887`, > 69.24597`, 69.68301`, 68.90541`, 69.07283`, 69.03297`, 69.18202`, > 69.64233`, 68.82818`, 69.24165`, 69.10265`, 68.98512`, 69.31551`, > 69.20435`, 68.93765`, 69.36661`, 68.71181`, 68.75662`, 69.35439`, > 69.74222`, 69.82326`, 69.90223`, 70.2992`, 69.83745`, 69.94847`, > 70.27479`, 70.67752`, 70.38903`, 70.37578`, 70.60668`, 70.16921`, > 69.85223`, 70.23353`, 70.28373`, 70.33881`, 69.81443`, 70.54739`, > 69.96746`, 69.73702`, 69.8604`, 70.87111`, 71.36657`, 71.1878`, > 70.75001`, 70.72998`, 71.32092`, 70.88794`, 70.9085`, 70.87662`, > 71.19803`, 71.31925`, 71.22916`, 71.35939`, 71.60205`, 70.97309`, > 71.1886`, 71.40319`, 71.39524`, 70.88752`, 71.27449`, 72.10289`, > 72.03197`, 71.9969`, 71.72577`, 71.92914`, 72.20518`, 72.29401`, > 72.5854`, 72.04673`, 71.80541`, 71.80464`, 73.06559`, 73.44548`, > 73.19223`, 73.37471`, 73.22554`, 72.88357`, 72.77826`, 73.26989`, > 73.96165`, 74.64342`, 73.92565`, 74.58767`, 74.31029`, 75.10003`, > 77.15504`, 60.78204`, 62.36303`, 66.40186`, 58.50708`, 70.00052`, > 70.99433`, 64.96417`, 70.47639`, 69.23383`, 64.90184`, 68.7749`, > 69.85805`, 62.52373`, 63.28805`, 63.52861`, 62.87456`, 63.91754`, > 64.32325`, 64.22405`, 64.59643`, 64.28548`, 63.78835`, 65.66404`, > 64.80838`, 65.63528`, 64.74897`, 64.79081`, 65.10988`, 65.55215`, > 65.30083`, 65.1426`, 65.09433`, 64.81397`, 65.95058`, 66.37511`, > 66.38624`, 66.31904`, 65.80919`, 66.09556`, 66.49077`, 66.32632`, > 66.59779`, 66.00909`, 66.45585`, 66.00818`, 66.46605`, 66.37783`, > 66.34685`, 66.31558`, 66.62303`, 66.79229`, 67.5336`, 67.15587`, > 66.78051`, 67.25544`, 66.79006`, 66.88298`, 68.1121`, 63.61572`, > 63.17978`, 65.67211`, 67.23403`, 67.4089`, 67.57913`, 67.20643`, > 67.10018`, 66.80557`, 67.09308`, 66.91372`, 66.77528`, 66.97572`, > 67.66639`, 67.62089`, 67.66841`, 67.32572`, 67.04153`, 66.96445`, > 67.07223`, 67.169`, 67.48077`, 67.67057`, 66.86465`, 67.04437`, > 67.72523`, 68.52969`, 67.8741`, 67.84693`, 68.26632`, 68.18364`, > 68.55723`, 67.77137`, 67.92976`, 67.72522`, 67.98916`, 68.0679`, > 67.772`, 68.11035`, 68.16623`, 68.61054`, 68.2893`, 68.38263`, > 68.6212`, 68.27802`, 67.93914`, 67.7105`, 68.351`, 68.14712`, > 67.97421`, 68.23682`, 68.05699`, 68.49856`, 68.58894`, 67.74098`, > 68.69765`, 68.63531`, 68.37844`, 69.11352`, 69.35385`, 69.5135`, > 69.11`, 69.64324`, 69.40655`, 69.18575`, 68.80709`, 69.11679`, > 69.02706`, 69.05703`, 69.14581`, 68.7308`, 68.9798`, 68.95303`, > 69.1639`, 68.81649`, 68.73746`, 69.00102`, 69.28222`, 69.37676`, > 68.90879`, 69.32318`, 69.63872`, 69.43581`, 68.97885`, 69.54252`, > 68.73497`, 69.20127`, 70.36167`, 70.10118`, 70.39507`, 70.03877`, > 69.76556`, 70.39131`, 70.0372`, 70.25908`, 69.87081`, 70.69845`, > 70.25756`, 69.7177`, 70.31993`, 69.95735`, 69.72691`, 70.22698`, > 70.02038`, 70.32035`, 70.39947`, 69.78074`, 69.7598`, 70.53827`, > 70.03449`, 70.59135`, 71.13378`, 71.15371`, 71.03018`, 70.93936`, > 70.78603`, 71.50695`, 71.57023`, 70.83563`, 70.96118`, 71.55428`, > 71.08274`, 71.49587`, 71.36997`, 71.49891`, 71.01177`, 71.62784`, > 71.36701`, 71.23426`, 70.90129`, 71.53087`, 72.441`, 72.5999`, > 71.79167`, 72.00806`, 72.01746`, 72.44981`, 71.92864`, 72.0908`, > 72.57398`, 72.53335`, 71.78483`, 72.57594`, 73.06795`, 73.18852`, > 73.39371`, 73.3754`, 73.67679`, 72.84789`, 72.99608`, 74.67822`, > 73.8507`, 74.35692`, 73.99906`, 73.92525`, 75.67784`, 76.10484`, > 78.2476`, 61.89619`, 69.86215`, 62.26801`, 71.40839`, 71.60925`, > 65.51351`, 71.86574`, 71.16645`, 64.53321`, 65.25053`, 69.62871`, > 65.10223`, 61.03526`, 63.12132`, 63.5968`, 63.47848`, 63.83162`, > 64.18388`, 64.66888`, 64.06363`, 64.38072`, 64.60295`, 64.81735`, > 65.22864`, 65.62354`, 65.62755`, 64.8584`, 65.6482`, 65.6904`, > 65.58218`, 65.08945`, 64.87234`, 65.68794`, 66.54461`, 66.23255`, > 65.91034`, 66.29882`, 66.33603`, 66.19024`, 66.12728`, 66.1938`, > 65.82389`, 66.61389`, 66.45299`, 66.25633`, 66.53703`, 66.28457`, > 65.90354`, 66.61969`, 66.59349`, 67.30641`, 67.41523`, 67.51658`, > 66.94071`, 67.11246`, 66.99107`, 66.94124`, 68.06898`, 67.47908`, > 63.00731`, 67.40208`, 68.75691`, 66.90827`, 67.28305`, 67.15978`, > 67.12405`, 67.07313`, 67.17665`, 66.74724`, 66.81865`, 67.43735`, > 67.37322`, 66.96049`, 67.40154`, 66.91834`, 66.93007`, 66.78425`, > 66.7842`, 67.15158`, 67.45025`, 67.68985`, 67.13767`, 67.60589`, > 67.96334`, 68.65674`, 68.42972`, 68.01111`, 68.61891`, 68.50647`, > 67.77439`, 68.09837`, 68.19228`, 68.54918`, 68.59413`, 68.65282`, > 68.40294`, 68.54259`, 68.59444`, 67.87885`, 68.0454`, 67.96346`, > 68.55092`, 68.07785`, 67.93252`, 68.5916`, 67.90891`, 68.63842`, > 68.6514`, 68.40634`, 68.19563`, 68.3391`, 68.13175`, 67.79551`, > 68.24471`, 67.96366`, 68.02669`, 68.07695`, 69.23339`, 69.22874`, > 68.9062`, 69.33247`, 69.53206`, 69.02418`, 69.26288`, 69.55433`, > 69.3664`, 68.96569`, 69.33038`, 69.10425`, 69.29199`, 69.26009`, > 68.71424`, 69.48488`, 69.48141`, 68.88311`, 68.83524`, 69.42378`, > 68.82387`, 69.06951`, 69.18528`, 69.26989`, 68.83727`, 69.11594`, > 69.39569`, 68.70258`, 70.39288`, 70.49606`, 70.11817`, 69.75304`, > 70.25238`, 70.28837`, 69.71807`, 70.13835`, 70.41752`, 69.91638`, > 69.7803`, 69.90789`, 70.29221`, 70.20136`, 70.42766`, 70.40239`, > 70.65713`, 69.7276`, 70.45174`, 70.52536`, 70.45682`, 70.52011`, > 70.25621`, 70.32714`, 71.39933`, 71.03487`, 71.61276`, 70.90129`, > 71.36831`, 71.46158`, 71.22939`, 71.59368`, 71.6476`, 71.33885`, > 71.13133`, 71.52388`, 70.95837`, 71.48199`, 70.85433`, 71.41922`, > 71.30872`, 71.22321`, 71.4506`, 70.76122`, 72.65576`, 71.96434`, > 72.3071`, 72.2446`, 72.38029`, 72.04211`, 71.77644`, 72.54877`, > 72.57381`, 71.90584`, 72.62022`, 72.4218`, 73.13823`, 73.60773`, > 73.2649`, 73.0769`, 73.69792`, 73.60551`, 72.87015`, 73.90142`, > 74.32431`, 73.87776`, 74.20972`, 74.47833`, 75.07304`, 76.3516`, > 78.36479`, 61.22021`, 72.63356`, 64.94291`, 73.02984`, 71.81569`, > 65.29123`, 60.90911`, 72.131`, 70.98853`, 61.7019`, 67.51436`, > 64.37789`, 63.2825`, 63.47892`, 63.66235`, 63.94637`, 63.93831`, > 63.94722`, 64.08187`, 64.68702`, 64.38337`, 63.91132`, 64.84282`, > 65.33216`, 65.2375`, 65.47348`, 65.16309`, 65.35727`, 65.59545`, > 64.70258`, 64.76966`, 65.55892`, 65.42338`, 66.54624`, 65.70133`, > 66.12315`, 66.2678`, 66.55539`, 66.42398`, 66.50633`, 66.27712`, > 66.42142`, 66.25827`, 66.1285`, 66.53558`, 66.32575`, 66.11991`, > 65.87925`, 65.70978`, 66.10198`, 67.57237`, 67.4361`, 67.00761`, > 67.21048`, 67.1921`, 67.39528`, 67.44979`, 68.18883`, 62.74094`, > 66.34954`, 65.69966`, 68.36264`, 67.52548`, 67.24632`, 67.21519`, > 67.45383`, 66.93472`, 67.6832`, 66.97218`, 66.73049`, 66.75153`, > 67.4346`, 66.92896`, 67.49282`, 66.93944`, 67.03135`, 66.91542`, > 66.97758`, 67.14932`, 67.53093`, 67.52202`, 67.27928`, 67.56893`, > 67.75773`, 68.10565`, 68.49664`, 68.5851`, 67.85579`, 68.60796`, > 68.19156`, 68.25828`, 68.15401`, 68.18623`, 68.16064`, 68.6097`, > 68.34391`, 68.65678`, 68.51914`, 67.72093`, 67.96986`, 67.75073`, > 68.09745`, 68.64602`, 68.2318`, 68.18244`, 68.15011`, 68.13611`, > 68.10048`, 68.53037`, 68.37728`, 68.17652`, 67.7452`, 67.93037`, > 68.25872`, 68.33639`, 68.27405`, 69.5816`, 68.70027`, 68.93075`, > 68.78663`, 69.0649`, 68.99285`, 68.99516`, 68.73929`, 69.47357`, > 69.08392`, 69.07281`, 69.62286`, 69.35683`, 69.16149`, 68.81413`, > 68.9529`, 69.47561`, 69.5506`, 69.38889`, 69.57241`, 69.37092`, > 68.92229`, 68.71081`, 69.2671`, 68.74473`, 68.81509`, 69.47472`, > 69.69307`, 69.65334`, 70.46902`, 70.00607`, 70.61711`, 70.51318`, > 69.97204`, 69.92313`, 70.46938`, 69.91923`, 69.71908`, 70.61155`, > 70.20868`, 70.27586`, 70.18348`, 70.5115`, 70.50015`, 70.24017`, > 70.001`, 70.21726`, 70.20554`, 69.97788`, 70.36632`, 70.38931`, > 70.18593`, 70.23168`, 70.74197`, 71.47899`, 71.41695`, 71.20207`, > 70.87987`, 71.26557`, 71.41653`, 71.24074`, 71.15528`, 71.20588`, > 70.98515`, 71.35642`, 71.21331`, 71.59639`, 71.25854`, 71.53325`, > 70.92787`, 71.54787`, 71.07293`, 70.86163`, 72.67319`, 71.77245`, > 72.64278`, 72.48159`, 71.9078`, 72.18324`, 72.55104`, 72.33861`, > 72.07098`, 72.30647`, 72.05185`, 72.75204`, 72.79178`, 73.50606`, > 73.68578`, 72.79593`, 73.41049`, 73.02077`, 73.20758`, 74.49237`, > 73.81263`, 73.81376`, 73.82642`, 73.81739`, 75.57544`, 77.23474`, > 60.05859`, 76.81927`, 66.72684`, 58.79456`, 67.89277`, 61.04946`, > 59.81693`, 70.75232`, 68.26774`, 69.30589`, 69.30199`, 67.015`}; > > In[60]:= lm = LinearModelFit[GaltonDat, {1, x}, x] > > Out[60]= FittedModel[\\!\\(\\* > PanelBox[ > TagBox[ > RowBox[{\33.88660435407788`\, \ \, \+\, > RowBox[{\0.5140930386233082`\, \ \, \x\}]}], > Short], > FrameMargins->5]\\)] > > In[62]:= lm[\BestFit\] > > Out[62]= 33.8866 + 0.514093 x > > In[63]:= r2 = Correlation[GaltonX, GaltonY] > > Out[63]= 0.501338 === Subject: Re: Difference Fit vs. Correlation > in the code below, using Correlation I get 0.501338, using Fit I get > 0.514093. > How come? > > Claus > > > In[47]:= GaltonX = {65.04851`, 63.25094`, 64.95532`, 65.7525`, > 61.13723`, 63.02254`, 65.37053`, 64.72398`, 66.06509`, 66.96738`, > 59.008`, 62.93203`, 63.67063`, 64.07386`, 64.68851`, 65.15466`, > 66.37353`, 65.57704`, 67.36765`, 66.75929`, 67.79764`, 69.5348`, > 62.54014`, 63.81016`, 64.4565`, 64.9665`, 64.70662`, 65.73829`, > 65.50141`, 65.55416`, 66.90294`, 66.57388`, 66.53198`, 67.90613`, > 68.29198`, 67.74123`, 68.46917`, 69.38327`, 71.81791`, 62.41615`, > 64.49083`, 64.4876`, 63.92303`, 65.44592`, 65.02977`, 65.67038`, > 68.66078`, 66.54597`, 64.85954`, 69.60692`, 64.8135`, 65.32703`, > 65.83169`, 65.83427`, 65.56135`, 65.8688`, 65.77339`, 67.09116`, > 66.61374`, 67.41075`, 67.27716`, 66.61134`, 68.17412`, 67.80555`, > 68.32529`, 68.07787`, 68.96795`, 68.9255`, 69.60862`, 70.35646`, > 70.00643`, 72.75425`, 62.82147`, 62.86855`, 63.91261`, 64.54118`, > 64.51906`, 66.02688`, 65.81011`, 66.01812`, 65.53742`, 65.73346`, > 66.77424`, 66.67869`, 66.97585`, 66.94021`, 66.84575`, 67.12008`, > 67.74181`, 68.27194`, 67.60691`, 68.44737`, 67.65832`, 68.71193`, > 69.32025`, 68.7403`, 69.13395`, 69.34995`, 68.6297`, 69.58258`, > 70.39517`, 71.19284`, 70.82429`, 71.65367`, 73.28133`, 63.03753`, > 63.66428`, 65.38311`, 64.60205`, 66.40661`, 65.76985`, 65.66729`, > 66.05712`, 66.54635`, 66.5723`, 66.64876`, 67.71899`, 68.48726`, > 67.82769`, 67.55801`, 68.07763`, 69.16715`, 68.693`, 68.61779`, > 68.64797`, 68.61666`, 70.36485`, 70.0099`, 70.13984`, 70.2073`, > 71.28063`, 70.90445`, 72.19036`, 74.96203`, 64.88218`, 65.55174`, > 65.65889`, 65.92826`, 65.94198`, 67.43646`, 67.48444`, 67.61344`, > 68.4518`, 68.49456`, 68.1056`, 69.48308`, 69.07389`, 69.39251`, > 69.44294`, 69.52131`, 70.15463`, 69.86911`, 70.44394`, 70.85393`, > 71.30074`, 72.13978`, 72.19045`, 75.43393`, 64.51788`, 66.36335`, > 65.56855`, 66.78957`, 66.91193`, 68.1714`, 67.50102`, 67.83492`, > 68.95255`, 69.26`, 68.74223`, 69.74288`, 70.29942`, 70.04402`, > 70.23559`, 70.88075`, 71.19091`, 72.37396`, 73.03345`, 74.8083`, > 67.39521`, 67.31523`, 67.77952`, 69.33827`, 68.72404`, 69.98991`, > 69.75383`, 70.65942`, 71.10882`, 72.4811`, 72.4801`, 67.52214`, > 68.23931`, 68.7997`, 69.89568`, 71.48641`, 70.76482`, 71.9137`, > 63.08399`, 68.23241`, 70.05787`, 70.83996`, 72.56944`, 67.93353`, > 67.54033`, 72.79855`, 62.67482`, 68.19196`, 65.07215`, 73.42952`, > 62.94125`, 62.53667`, 69.90248`, 71.07217`, 71.11059`, 69.48402`, > 70.18338`, 65.46124`, 62.04073`, 63.60063`, 65.60613`, 68.02969`, > 61.81571`, 63.78886`, 64.89023`, 65.79072`, 66.42371`, 68.80877`, > 61.76521`, 64.30302`, 63.69064`, 64.99662`, 65.34899`, 64.81278`, > 65.71736`, 66.03148`, 67.04912`, 67.77522`, 69.04964`, 62.1833`, > 62.76393`, 63.88391`, 65.41055`, 64.62347`, 65.64621`, 66.16257`, > 65.99538`, 65.79786`, 67.42936`, 67.11933`, 67.32907`, 67.86233`, > 68.31609`, 67.96359`, 68.68615`, 71.18085`, 62.4296`, 62.88524`, > 64.07313`, 63.88597`, 64.8272`, 65.39653`, 64.77344`, 68.66581`, > 65.19783`, 64.32621`, 66.08278`, 69.01679`, 64.50194`, 66.07654`, > 65.73631`, 66.45485`, 65.63018`, 66.39423`, 67.33687`, 66.83938`, > 66.69739`, 67.34708`, 67.35319`, 67.93575`, 67.76608`, 68.11569`, > 68.2548`, 68.83427`, 69.40758`, 69.32068`, 70.48`, 70.06429`, > 70.63764`, 62.41134`, 63.15274`, 63.51409`, 63.91446`, 64.61683`, > 64.86185`, 65.91332`, 66.1992`, 66.45978`, 65.50286`, 66.87795`, > 67.0791`, 66.83256`, 67.18231`, 66.51763`, 66.95295`, 66.63586`, > 68.18453`, 67.60565`, 68.27918`, 67.97994`, 69.00094`, 69.31139`, > 68.88641`, 68.94824`, 69.42186`, 69.49516`, 70.34647`, 69.92358`, > 70.69078`, 70.56571`, 72.40997`, 72.47685`, 62.72118`, 63.9001`, > 64.50433`, 64.81813`, 65.37582`, 65.82612`, 66.29436`, 65.81042`, > 66.80854`, 67.16724`, 67.30525`, 67.54577`, 67.86855`, 68.35003`, > 67.60818`, 68.48397`, 68.56724`, 69.07405`, 68.56831`, 69.15373`, > 68.60744`, 68.5443`, 69.65536`, 70.41632`, 69.97528`, 70.26613`, > 71.31667`, 71.29178`, 72.59442`, 64.40268`, 64.9127`, 66.34756`, > 66.04291`, 65.69477`, 66.71512`, 66.64971`, 68.33241`, 67.94335`, > 67.96734`, 68.27657`, 68.75008`, 69.05441`, 69.00755`, 69.39488`, > 69.7628`, 69.6464`, 70.45427`, 69.89852`, 70.984`, 71.22015`, > 71.45442`, 71.60966`, 73.20296`, 63.89132`, 65.99384`, 66.0424`, > 67.47658`, 66.68527`, 68.27034`, 67.72898`, 68.28372`, 68.39453`, > 69.12925`, 69.10844`, 69.74196`, 69.9987`, 69.56148`, 69.97779`, > 70.88691`, 70.64687`, 72.26404`, 71.50569`, 73.01402`, 66.20254`, > 67.26312`, 67.8086`, 69.08284`, 69.35107`, 69.59962`, 70.08948`, > 70.18385`, 71.26955`, 72.07717`, 72.33894`, 67.06776`, 67.85929`, > 69.07274`, 69.59893`, 69.73728`, 70.54066`, 72.40962`, 72.78889`, > 68.10144`, 68.6106`, 71.293`, 72.09445`, 74.69236`, 71.16246`, > 68.30804`, 60.41857`, 63.94459`, 63.06849`, 63.98036`, 73.89524`, > 72.03687`, 61.02471`, 65.39914`, 71.96564`, 71.29643`, 65.15837`, > 68.90263`, 64.45192`, 63.99469`, 66.46124`, 67.12556`, 62.27941`, > 63.8488`, 65.43612`, 65.62145`, 66.16956`, 67.62675`, 60.21393`, > 62.99378`, 63.57239`, 65.15088`, 65.13462`, 64.79732`, 66.24856`, > 66.22743`, 66.6056`, 67.99167`, 69.04862`, 62.12902`, 63.16227`, > 64.45497`, 63.75483`, 64.63959`, 64.59106`, 66.06003`, 65.98544`, > 65.66176`, 67.11501`, 67.31302`, 67.16149`, 68.38679`, 67.64175`, > 67.55466`, 68.53614`, 70.02702`, 61.07412`, 62.72387`, 64.28642`, > 64.11073`, 63.68318`, 64.68393`, 64.66753`, 67.95848`, 64.60933`, > 66.07775`, 65.25267`, 69.67201`, 65.33965`, 65.54375`, 66.1112`, > 66.22968`, 66.00879`, 66.03248`, 65.94624`, 67.09734`, 66.98893`, > 67.38837`, 67.4075`, 67.31108`, 68.27151`, 68.33586`, 67.56752`, > 68.23182`, 69.07604`, 68.77033`, 70.49154`, 70.00767`, 69.52007`, > 61.50617`, 62.93875`, 64.10318`, 63.85157`, 65.08731`, 64.62588`, > 65.8912`, 66.24386`, 65.66031`, 66.05344`, 66.30711`, 67.15303`, > 66.90986`, 66.89436`, 66.56566`, 67.23789`, 67.05684`, 67.94515`, > 67.94026`, 67.84234`, 67.91887`, 68.63961`, 68.60477`, 69.04036`, > 69.03336`, 69.12497`, 68.53779`, 70.24335`, 69.84308`, 69.90057`, > 71.48946`, 72.37013`, 71.94413`, 61.01904`, 63.0108`, 64.5793`, > 65.39658`, 64.84995`, 65.54542`, 65.56421`, 66.09747`, 67.40602`, > 66.5839`, 67.41035`, 67.21634`, 68.23175`, 67.88053`, 68.0153`, > 67.69332`, 68.85462`, 68.73264`, 69.0711`, 68.79964`, 68.79876`, > 69.32241`, 69.60923`, 69.76071`, 70.1611`, 70.12109`, 71.10802`, > 71.44164`, 71.75006`, 64.35591`, 65.16253`, 66.09529`, 65.78674`, > 65.53927`, 66.71703`, 67.17284`, 67.16853`, 68.06061`, 67.85988`, > 68.1968`, 69.29537`, 68.84067`, 69.18095`, 68.69659`, 69.45833`, > 70.0483`, 69.6916`, 70.20658`, 70.79086`, 70.87977`, 71.30702`, > 72.3266`, 72.7824`, 64.40052`, 64.89121`, 65.84506`, 67.35461`, > 67.44953`, 67.86439`, 67.92443`, 68.49998`, 67.60602`, 69.37288`, > 69.34931`, 69.48306`, 70.21887`, 70.02161`, 69.83698`, 69.6041`, > 71.49829`, 72.16894`, 72.41045`, 72.52521`, 64.6702`, 66.78417`, > 67.83401`, 68.15907`, 69.19301`, 68.86739`, 70.11126`, 70.12007`, > 71.03691`, 71.43196`, 72.04564`, 72.738`, 68.02564`, 69.04939`, > 68.86356`, 69.63421`, 71.24085`, 71.95679`, 72.89983`, 65.86028`, > 68.48883`, 70.72676`, 72.34582`, 72.59922`, 68.82986`, 73.49987`, > 70.0599`, 67.9291`, 64.66998`, 60.7795`, 74.94058`, 70.64925`, > 60.91526`, 65.28934`, 71.362`, 71.66893`, 62.68868`, 71.39326`, > 66.56302`, 67.18788`, 62.532`, 64.85512`, 66.94161`, 62.3603`, > 63.58145`, 65.44633`, 65.00539`, 66.43717`, 66.6676`, 59.4898`, > 63.00108`, 64.0892`, 64.0753`, 64.52103`, 65.19231`, 66.30604`, > 66.03081`, 66.83096`, 68.19724`, 68.6599`, 61.29369`, 63.26089`, > 63.86162`, 64.13176`, 64.81105`, 64.55987`, 66.19437`, 66.5`, > 66.43436`, 67.30468`, 67.36559`, 67.29162`, 67.69874`, 68.38221`, > 67.76712`, 69.29587`, 69.66477`, 60.03436`, 62.1356`, 63.64047`, > 63.82278`, 64.46555`, 64.73798`, 65.43021`, 65.07381`, 69.29517`, > 67.67996`, 64.94267`, 69.47933`, 65.05963`, 65.01253`, 65.61963`, > 65.94819`, 65.68803`, 65.87689`, 65.91481`, 67.41946`, 66.53833`, > 67.41995`, 67.21977`, 67.33721`, 68.11283`, 68.02017`, 68.02829`, > 68.35139`, 68.80254`, 69.49307`, 70.2297`, 69.71997`, 70.16651`, > 61.07369`, 62.66947`, 64.32254`, 64.27362`, 64.96148`, 64.77222`, > 66.2365`, 66.10686`, 66.42772`, 66.22727`, 65.87574`, 67.03017`, > 67.48545`, 66.7367`, 66.69181`, 67.31766`, 67.1219`, 67.82592`, > 68.4376`, 67.74551`, 68.0934`, 67.71665`, 68.99349`, 69.24616`, > 69.2828`, 69.26254`, 68.75605`, 69.62519`, 69.61942`, 69.94715`, > 70.58916`, 72.34058`, 71.56142`, 72.94457`, 63.33777`, 64.3445`, > 65.14077`, 65.2424`, 65.90397`, 65.98763`, 65.57065`, 65.82733`, > 66.88576`, 66.98594`, 67.41537`, 67.93319`, 67.77812`, 68.44999`, > 68.32281`, 68.35148`, 68.73678`, 68.97673`, 69.31931`, 68.80442`, > 68.90434`, 69.80381`, 69.66712`, 70.38052`, 70.29892`, 71.02634`, > 71.28432`, 72.03259`, 63.26539`, 64.87623`, 65.72722`, 66.13831`, > 66.48902`, 66.06395`, 66.73532`, 67.12329`, 67.57161`, 68.18286`, > 68.33868`, 68.14658`, 69.17022`, 69.17597`, 68.52789`, 68.84874`, > 69.69833`, 69.86528`, 70.48646`, 71.16238`, 70.58946`, 70.54353`, > 72.38576`, 73.18522`, 64.12344`, 64.62855`, 65.74244`, 67.11563`, > 66.81497`, 68.38001`, 68.33835`, 68.25066`, 68.36488`, 68.67873`, > 68.70293`, 69.0466`, 70.17375`, 69.86849`, 70.15821`, 70.24204`, > 71.41811`, 70.66031`, 72.42614`, 73.04341`, 64.6891`, 67.09928`, > 67.79858`, 68.37299`, 69.19364`, 68.5938`, 69.86969`, 70.17952`, > 70.51811`, 71.00743`, 71.83086`, 72.81121`, 67.95451`, 67.81317`, > 69.32812`, 70.45127`, 71.38916`, 72.31022`, 71.8821`, 64.61601`, > 67.75382`, 69.90335`, 70.87039`, 72.71533`, 69.03942`, 72.44463`, > 69.07253`, 70.1758`, 72.37219`, 59.63777`, 73.27737`, 68.12621`, > 63.15234`, 66.00489`, 71.45303`, 68.1456`, 65.25527`, 70.41584`, > 68.38452`, 61.89133`, 64.98391`, 66.21887`, 59.48391`, 62.77645`, > 63.86507`, 64.56486`, 65.60265`, 66.28333`, 70.55256`, 62.14539`, > 64.37906`, 64.35191`, 64.91304`, 65.33085`, 65.17545`, 66.10285`, > 66.05004`, 67.38231`, 67.83999`, 70.27309`, 63.19263`, 63.66834`, > 64.12671`, 64.71388`, 65.14662`, 65.94428`, 65.67785`, 65.95134`, > 67.30819`, 66.69404`, 66.56885`, 66.80951`, 68.24011`, 67.5344`, > 68.4157`, 69.09588`, 70.81036`, 61.68183`, 63.04493`, 64.34945`, > 63.89336`, 65.48176`, 64.726`, 64.65128`, 67.47271`, 66.76701`, > 64.98147`, 69.38684`, 63.7123`, 64.63358`, 66.00037`, 65.96621`, > 66.49751`, 66.27177`, 65.67892`, 66.86814`, 66.73495`, 66.53357`, > 67.05051`, 67.04958`, 67.55908`, 67.58076`, 67.51942`, 68.12592`, > 68.57465`, 68.52484`, 69.20286`, 69.7551`, 69.91868`, 70.50329`, > 62.83528`, 63.24504`, 64.44602`, 64.31819`, 64.73521`, 64.72352`, > 65.97741`, 65.63739`, 65.83449`, 65.87064`, 66.61001`, 66.75821`, > 66.77012`, 67.21373`, 67.09047`, 66.93359`, 68.03852`, 67.98476`, > 68.25046`, 68.26078`, 68.21235`, 68.54029`, 68.50469`, 69.13248`, > 69.21981`, 69.34385`, 69.41153`, 70.25056`, 69.68641`, 70.51091`, > 71.29598`, 72.20218`, 72.33929`, 62.91628`, 63.93525`, 64.59851`, > 65.47401`, 65.864`, 66.30684`, 65.77587`, 66.48386`, 67.31983`, > 67.39901`, 67.05939`, 68.45161`, 67.7061`, 68.08389`, 67.58923`, > 67.80388`, 69.25919`, 69.05302`, 68.70921`, 69.02788`, 68.94943`, > 68.81536`, 69.91801`, 70.45072`, 69.96349`, 69.75787`, 71.38281`, > 71.08122`, 72.74936`, 65.26855`, 66.01549`, 65.5142`, 65.62374`, > 65.92199`, 67.11129`, 66.89727`, 67.94195`, 67.7274`, 67.54999`, > 67.96013`, 68.83038`, 69.43917`, 68.55957`, 69.10638`, 70.4814`, > 69.92992`, 70.04238`, 69.56779`, 71.01077`, 70.62603`, 71.46383`, > 71.62112`, 73.87758`, 65.00573`, 66.30354`, 65.86743`, 66.86667`, > 67.15958`, 68.06904`, 67.57382`, 67.63354`, 69.41356`, 68.87192`, > 69.07779`, 69.81177`, 70.01463`, 69.56649`, 70.254`, 70.68296`, > 70.87874`, 72.45099`, 73.04359`, 74.40915`, 67.40139`, 66.53122`, > 68.04593`, 68.82772`, 69.33069`, 70.34676`, 70.173`, 70.80883`, > 70.7029`, 72.35959`, 72.3661`, 67.17534`, 67.84045`, 68.9053`, > 70.3752`, 71.18523`, 71.41254`, 71.70673`, 72.60072`, 67.57652`, > 68.55814`, 70.95019`, 71.99783`, 75.17469`, 73.07157`, 69.92407`, > 65.54323`, 72.56261`, 72.15051`, 63.22006`, 73.2645`, 65.81296`, > 67.70657`, 66.99681`, 71.33181`, 71.78314`, 70.73837`, 70.30609`}; > > In[59]:= GaltonY = {59.77827`, 63.21404`, 63.34242`, 62.79238`, > 64.28113`, 64.24221`, 64.08231`, 63.99574`, 64.61338`, 63.97944`, > 65.24451`, 65.35102`, 65.67992`, 65.43664`, 65.29391`, 64.79017`, > 65.01881`, 65.5464`, 65.08145`, 65.49008`, 65.1352`, 65.51262`, > 66.58436`, 66.37842`, 66.14782`, 65.97259`, 65.95887`, 66.45202`, > 65.74797`, 65.97164`, 65.90548`, 65.90773`, 66.47103`, 65.75023`, > 66.34666`, 66.08577`, 66.28037`, 66.34354`, 66.41711`, 67.22558`, > 67.46394`, 66.99362`, 66.76647`, 67.0342`, 66.84316`, 69.2989`, > 69.09114`, 61.66358`, 65.7288`, 68.98012`, 67.37397`, 67.17459`, > 67.06712`, 67.29446`, 67.62665`, 67.47923`, 66.92162`, 67.58324`, > 67.21191`, 66.81629`, 67.24268`, 67.51036`, 67.57026`, 67.17258`, > 67.54129`, 67.37113`, 67.59714`, 67.25104`, 66.82533`, 66.72679`, > 66.92996`, 67.64847`, 68.04291`, 68.4885`, 68.04777`, 68.34573`, > 68.33829`, 68.3138`, 68.18333`, 68.51056`, 68.12014`, 68.31563`, > 68.04774`, 68.61273`, 67.9425`, 68.08381`, 68.36754`, 67.85181`, > 68.19806`, 68.01897`, 68.23431`, 67.89742`, 68.62409`, 67.97912`, > 68.2668`, 67.94192`, 68.62072`, 68.23857`, 68.58554`, 68.06568`, > 68.38188`, 67.75943`, 68.59991`, 67.91483`, 67.83861`, 68.77562`, > 69.60782`, 69.69143`, 69.41491`, 69.68931`, 69.20775`, 69.45627`, > 69.59614`, 69.27994`, 69.52338`, 68.74406`, 69.30987`, 69.22571`, > 69.24073`, 69.4912`, 69.11921`, 68.93751`, 69.45774`, 69.27599`, > 69.22869`, 68.70547`, 69.34638`, 68.87137`, 69.30262`, 69.1579`, > 69.62727`, 69.11014`, 69.09596`, 69.03281`, 69.85677`, 70.06274`, > 69.89765`, 70.26185`, 70.52663`, 70.52744`, 69.7865`, 70.36684`, > 69.97604`, 69.83308`, 70.69951`, 70.16871`, 70.11632`, 69.95433`, > 70.31279`, 69.80903`, 69.96792`, 69.93939`, 69.73486`, 70.08397`, > 70.01015`, 70.65025`, 70.01253`, 70.09077`, 71.34319`, 70.81542`, > 71.44929`, 71.18676`, 71.66276`, 71.39516`, 70.73612`, 71.2608`, > 71.04721`, 71.2592`, 70.89486`, 71.31732`, 71.55712`, 71.17701`, > 71.03412`, 71.37275`, 71.64741`, 71.1205`, 70.91756`, 71.66455`, > 72.39198`, 71.87928`, 72.34482`, 72.17265`, 72.52078`, 71.98836`, > 72.34482`, 72.45347`, 72.26945`, 71.96844`, 72.18169`, 72.7864`, > 73.0414`, 72.87858`, 73.17304`, 73.63274`, 72.88245`, 73.18148`, > 74.3209`, 74.40727`, 73.76791`, 73.92119`, 73.75503`, 75.56214`, > 75.70222`, 77.21338`, 61.28882`, 74.28343`, 70.93102`, 75.34802`, > 61.78758`, 64.00009`, 62.4658`, 73.70465`, 66.3495`, 62.20543`, > 65.421`, 63.9922`, 62.78458`, 63.52486`, 63.49966`, 62.89658`, > 63.72784`, 63.73231`, 64.39579`, 63.70072`, 64.44796`, 64.2795`, > 65.18412`, 65.10118`, 65.56277`, 64.94454`, 65.14227`, 65.16843`, > 65.58149`, 65.63474`, 64.87191`, 65.4176`, 64.7231`, 65.84559`, > 65.77333`, 66.67371`, 66.54726`, 66.43228`, 66.3326`, 66.24935`, > 66.39759`, 66.69366`, 66.22114`, 66.43499`, 66.65758`, 65.76873`, > 66.20784`, 66.30166`, 65.81894`, 66.34562`, 66.88369`, 66.8162`, > 67.36245`, 67.68308`, 67.19885`, 67.26903`, 67.45131`, 68.95907`, > 62.013`, 64.10658`, 66.00879`, 65.77796`, 66.94446`, 66.81229`, > 67.01431`, 67.43705`, 66.8442`, 67.25391`, 67.52273`, 67.17782`, > 67.6068`, 66.8991`, 66.74675`, 67.16928`, 67.23833`, 66.75589`, > 66.79828`, 67.488`, 67.1104`, 67.06455`, 66.93899`, 67.54723`, > 66.85662`, 67.70971`, 67.88296`, 68.66534`, 68.58164`, 68.44493`, > 68.41199`, 68.44665`, 68.38258`, 67.92987`, 68.3033`, 67.97479`, > 68.18304`, 68.57984`, 68.56974`, 67.81854`, 67.8796`, 68.22794`, > 68.01258`, 67.85023`, 67.80077`, 68.59968`, 68.08671`, 67.87656`, > 68.47849`, 68.60006`, 68.07838`, 68.08199`, 67.73211`, 68.4132`, > 68.59541`, 68.28458`, 68.06489`, 68.41445`, 69.36998`, 69.00435`, > 69.37297`, 68.89496`, 69.37382`, 69.34415`, 68.96686`, 69.59887`, > 69.24597`, 69.68301`, 68.90541`, 69.07283`, 69.03297`, 69.18202`, > 69.64233`, 68.82818`, 69.24165`, 69.10265`, 68.98512`, 69.31551`, > 69.20435`, 68.93765`, 69.36661`, 68.71181`, 68.75662`, 69.35439`, > 69.74222`, 69.82326`, 69.90223`, 70.2992`, 69.83745`, 69.94847`, > 70.27479`, 70.67752`, 70.38903`, 70.37578`, 70.60668`, 70.16921`, > 69.85223`, 70.23353`, 70.28373`, 70.33881`, 69.81443`, 70.54739`, > 69.96746`, 69.73702`, 69.8604`, 70.87111`, 71.36657`, 71.1878`, > 70.75001`, 70.72998`, 71.32092`, 70.88794`, 70.9085`, 70.87662`, > 71.19803`, 71.31925`, 71.22916`, 71.35939`, 71.60205`, 70.97309`, > 71.1886`, 71.40319`, 71.39524`, 70.88752`, 71.27449`, 72.10289`, > 72.03197`, 71.9969`, 71.72577`, 71.92914`, 72.20518`, 72.29401`, > 72.5854`, 72.04673`, 71.80541`, 71.80464`, 73.06559`, 73.44548`, > 73.19223`, 73.37471`, 73.22554`, 72.88357`, 72.77826`, 73.26989`, > 73.96165`, 74.64342`, 73.92565`, 74.58767`, 74.31029`, 75.10003`, > 77.15504`, 60.78204`, 62.36303`, 66.40186`, 58.50708`, 70.00052`, > 70.99433`, 64.96417`, 70.47639`, 69.23383`, 64.90184`, 68.7749`, > 69.85805`, 62.52373`, 63.28805`, 63.52861`, 62.87456`, 63.91754`, > 64.32325`, 64.22405`, 64.59643`, 64.28548`, 63.78835`, 65.66404`, > 64.80838`, 65.63528`, 64.74897`, 64.79081`, 65.10988`, 65.55215`, > 65.30083`, 65.1426`, 65.09433`, 64.81397`, 65.95058`, 66.37511`, > 66.38624`, 66.31904`, 65.80919`, 66.09556`, 66.49077`, 66.32632`, > 66.59779`, 66.00909`, 66.45585`, 66.00818`, 66.46605`, 66.37783`, > 66.34685`, 66.31558`, 66.62303`, 66.79229`, 67.5336`, 67.15587`, > 66.78051`, 67.25544`, 66.79006`, 66.88298`, 68.1121`, 63.61572`, > 63.17978`, 65.67211`, 67.23403`, 67.4089`, 67.57913`, 67.20643`, > 67.10018`, 66.80557`, 67.09308`, 66.91372`, 66.77528`, 66.97572`, > 67.66639`, 67.62089`, 67.66841`, 67.32572`, 67.04153`, 66.96445`, > 67.07223`, 67.169`, 67.48077`, 67.67057`, 66.86465`, 67.04437`, > 67.72523`, 68.52969`, 67.8741`, 67.84693`, 68.26632`, 68.18364`, > 68.55723`, 67.77137`, 67.92976`, 67.72522`, 67.98916`, 68.0679`, > 67.772`, 68.11035`, 68.16623`, 68.61054`, 68.2893`, 68.38263`, > 68.6212`, 68.27802`, 67.93914`, 67.7105`, 68.351`, 68.14712`, > 67.97421`, 68.23682`, 68.05699`, 68.49856`, 68.58894`, 67.74098`, > 68.69765`, 68.63531`, 68.37844`, 69.11352`, 69.35385`, 69.5135`, > 69.11`, 69.64324`, 69.40655`, 69.18575`, 68.80709`, 69.11679`, > 69.02706`, 69.05703`, 69.14581`, 68.7308`, 68.9798`, 68.95303`, > 69.1639`, 68.81649`, 68.73746`, 69.00102`, 69.28222`, 69.37676`, > 68.90879`, 69.32318`, 69.63872`, 69.43581`, 68.97885`, 69.54252`, > 68.73497`, 69.20127`, 70.36167`, 70.10118`, 70.39507`, 70.03877`, > 69.76556`, 70.39131`, 70.0372`, 70.25908`, 69.87081`, 70.69845`, > 70.25756`, 69.7177`, 70.31993`, 69.95735`, 69.72691`, 70.22698`, > 70.02038`, 70.32035`, 70.39947`, 69.78074`, 69.7598`, 70.53827`, > 70.03449`, 70.59135`, 71.13378`, 71.15371`, 71.03018`, 70.93936`, > 70.78603`, 71.50695`, 71.57023`, 70.83563`, 70.96118`, 71.55428`, > 71.08274`, 71.49587`, 71.36997`, 71.49891`, 71.01177`, 71.62784`, > 71.36701`, 71.23426`, 70.90129`, 71.53087`, 72.441`, 72.5999`, > 71.79167`, 72.00806`, 72.01746`, 72.44981`, 71.92864`, 72.0908`, > 72.57398`, 72.53335`, 71.78483`, 72.57594`, 73.06795`, 73.18852`, > 73.39371`, 73.3754`, 73.67679`, 72.84789`, 72.99608`, 74.67822`, > 73.8507`, 74.35692`, 73.99906`, 73.92525`, 75.67784`, 76.10484`, > 78.2476`, 61.89619`, 69.86215`, 62.26801`, 71.40839`, 71.60925`, > 65.51351`, 71.86574`, 71.16645`, 64.53321`, 65.25053`, 69.62871`, > 65.10223`, 61.03526`, 63.12132`, 63.5968`, 63.47848`, 63.83162`, > 64.18388`, 64.66888`, 64.06363`, 64.38072`, 64.60295`, 64.81735`, > 65.22864`, 65.62354`, 65.62755`, 64.8584`, 65.6482`, 65.6904`, > 65.58218`, 65.08945`, 64.87234`, 65.68794`, 66.54461`, 66.23255`, > 65.91034`, 66.29882`, 66.33603`, 66.19024`, 66.12728`, 66.1938`, > 65.82389`, 66.61389`, 66.45299`, 66.25633`, 66.53703`, 66.28457`, > 65.90354`, 66.61969`, 66.59349`, 67.30641`, 67.41523`, 67.51658`, > 66.94071`, 67.11246`, 66.99107`, 66.94124`, 68.06898`, 67.47908`, > 63.00731`, 67.40208`, 68.75691`, 66.90827`, 67.28305`, 67.15978`, > 67.12405`, 67.07313`, 67.17665`, 66.74724`, 66.81865`, 67.43735`, > 67.37322`, 66.96049`, 67.40154`, 66.91834`, 66.93007`, 66.78425`, > 66.7842`, 67.15158`, 67.45025`, 67.68985`, 67.13767`, 67.60589`, > 67.96334`, 68.65674`, 68.42972`, 68.01111`, 68.61891`, 68.50647`, > 67.77439`, 68.09837`, 68.19228`, 68.54918`, 68.59413`, 68.65282`, > 68.40294`, 68.54259`, 68.59444`, 67.87885`, 68.0454`, 67.96346`, > 68.55092`, 68.07785`, 67.93252`, 68.5916`, 67.90891`, 68.63842`, > 68.6514`, 68.40634`, 68.19563`, 68.3391`, 68.13175`, 67.79551`, > 68.24471`, 67.96366`, 68.02669`, 68.07695`, 69.23339`, 69.22874`, > 68.9062`, 69.33247`, 69.53206`, 69.02418`, 69.26288`, 69.55433`, > 69.3664`, 68.96569`, 69.33038`, 69.10425`, 69.29199`, 69.26009`, > 68.71424`, 69.48488`, 69.48141`, 68.88311`, 68.83524`, 69.42378`, > 68.82387`, 69.06951`, 69.18528`, 69.26989`, 68.83727`, 69.11594`, > 69.39569`, 68.70258`, 70.39288`, 70.49606`, 70.11817`, 69.75304`, > 70.25238`, 70.28837`, 69.71807`, 70.13835`, 70.41752`, 69.91638`, > 69.7803`, 69.90789`, 70.29221`, 70.20136`, 70.42766`, 70.40239`, > 70.65713`, 69.7276`, 70.45174`, 70.52536`, 70.45682`, 70.52011`, > 70.25621`, 70.32714`, 71.39933`, 71.03487`, 71.61276`, 70.90129`, > 71.36831`, 71.46158`, 71.22939`, 71.59368`, 71.6476`, 71.33885`, > 71.13133`, 71.52388`, 70.95837`, 71.48199`, 70.85433`, 71.41922`, > 71.30872`, 71.22321`, 71.4506`, 70.76122`, 72.65576`, 71.96434`, > 72.3071`, 72.2446`, 72.38029`, 72.04211`, 71.77644`, 72.54877`, > 72.57381`, 71.90584`, 72.62022`, 72.4218`, 73.13823`, 73.60773`, > 73.2649`, 73.0769`, 73.69792`, 73.60551`, 72.87015`, 73.90142`, > 74.32431`, 73.87776`, 74.20972`, 74.47833`, 75.07304`, 76.3516`, > 78.36479`, 61.22021`, 72.63356`, 64.94291`, 73.02984`, 71.81569`, > 65.29123`, 60.90911`, 72.131`, 70.98853`, 61.7019`, 67.51436`, > 64.37789`, 63.2825`, 63.47892`, 63.66235`, 63.94637`, 63.93831`, > 63.94722`, 64.08187`, 64.68702`, 64.38337`, 63.91132`, 64.84282`, > 65.33216`, 65.2375`, 65.47348`, 65.16309`, 65.35727`, 65.59545`, > 64.70258`, 64.76966`, 65.55892`, 65.42338`, 66.54624`, 65.70133`, > 66.12315`, 66.2678`, 66.55539`, 66.42398`, 66.50633`, 66.27712`, > 66.42142`, 66.25827`, 66.1285`, 66.53558`, 66.32575`, 66.11991`, > 65.87925`, 65.70978`, 66.10198`, 67.57237`, 67.4361`, 67.00761`, > 67.21048`, 67.1921`, 67.39528`, 67.44979`, 68.18883`, 62.74094`, > 66.34954`, 65.69966`, 68.36264`, 67.52548`, 67.24632`, 67.21519`, > 67.45383`, 66.93472`, 67.6832`, 66.97218`, 66.73049`, 66.75153`, > 67.4346`, 66.92896`, 67.49282`, 66.93944`, 67.03135`, 66.91542`, > 66.97758`, 67.14932`, 67.53093`, 67.52202`, 67.27928`, 67.56893`, > 67.75773`, 68.10565`, 68.49664`, 68.5851`, 67.85579`, 68.60796`, > 68.19156`, 68.25828`, 68.15401`, 68.18623`, 68.16064`, 68.6097`, > 68.34391`, 68.65678`, 68.51914`, 67.72093`, 67.96986`, 67.75073`, > 68.09745`, 68.64602`, 68.2318`, 68.18244`, 68.15011`, 68.13611`, > 68.10048`, 68.53037`, 68.37728`, 68.17652`, 67.7452`, 67.93037`, > 68.25872`, 68.33639`, 68.27405`, 69.5816`, 68.70027`, 68.93075`, > 68.78663`, 69.0649`, 68.99285`, 68.99516`, 68.73929`, 69.47357`, > 69.08392`, 69.07281`, 69.62286`, 69.35683`, 69.16149`, 68.81413`, > 68.9529`, 69.47561`, 69.5506`, 69.38889`, 69.57241`, 69.37092`, > 68.92229`, 68.71081`, 69.2671`, 68.74473`, 68.81509`, 69.47472`, > 69.69307`, 69.65334`, 70.46902`, 70.00607`, 70.61711`, 70.51318`, > 69.97204`, 69.92313`, 70.46938`, 69.91923`, 69.71908`, 70.61155`, > 70.20868`, 70.27586`, 70.18348`, 70.5115`, 70.50015`, 70.24017`, > 70.001`, 70.21726`, 70.20554`, 69.97788`, 70.36632`, 70.38931`, > 70.18593`, 70.23168`, 70.74197`, 71.47899`, 71.41695`, 71.20207`, > 70.87987`, 71.26557`, 71.41653`, 71.24074`, 71.15528`, 71.20588`, > 70.98515`, 71.35642`, 71.21331`, 71.59639`, 71.25854`, 71.53325`, > 70.92787`, 71.54787`, 71.07293`, 70.86163`, 72.67319`, 71.77245`, > 72.64278`, 72.48159`, 71.9078`, 72.18324`, 72.55104`, 72.33861`, > 72.07098`, 72.30647`, 72.05185`, 72.75204`, 72.79178`, 73.50606`, > 73.68578`, 72.79593`, 73.41049`, 73.02077`, 73.20758`, 74.49237`, > 73.81263`, 73.81376`, 73.82642`, 73.81739`, 75.57544`, 77.23474`, > 60.05859`, 76.81927`, 66.72684`, 58.79456`, 67.89277`, 61.04946`, > 59.81693`, 70.75232`, 68.26774`, 69.30589`, 69.30199`, 67.015`}; > > In[60]:= lm = LinearModelFit[GaltonDat, {1, x}, x] > > Out[60]= FittedModel[\\!\\(\\* > PanelBox[ > TagBox[ > RowBox[{\33.88660435407788`\, \ \, \+\, > RowBox[{\0.5140930386233082`\, \ \, \x\}]}], > Short], > FrameMargins->5]\\)] > > In[62]:= lm[\BestFit\] > > Out[62]= 33.8866 + 0.514093 x > > In[63]:= r2 = Correlation[GaltonX, GaltonY] > > Out[63]= 0.501338 > The correlation and slope are two different quantities. Correlation gives a measure of how well one variable could predict the other, while slope is part of the linear prediction. Note, also that correlation is bounded by -1 and 1, while slope could be outside that range. If we take the formulas from simple linear regression, we see that the results are correct and that correlation and slope will only be equal if the x and y sums of squares, sxx and syy, are equal. In[3]:= xbar = Mean[GaltonX]; In[4]:= ybar = Mean[GaltonY]; In[5]:= n = Length[GaltonX]; In[6]:= sxy = GaltonX.GaltonY - n*xbar*ybar Out[6]= 4171.58 In[7]:= sxx = GaltonX.GaltonX - n*xbar^2 Out[7]= 8114.44 In[8]:= syy = GaltonY.GaltonY - n*ybar^2 Out[8]= 8532.58 In[9]:= cor = sxy/Sqrt[sxx*syy] Out[9]= 0.501338 In[10]:= slope = sxy/sxx Out[10]= 0.514093 Darren Glosemeyer Wolfram Research === Subject: Stirling 1st problem in Infinite sums The problem is that I can't get Mathematica to give values for the Stirling 1st Infinite sums. Daniel Lichenbau said I should apply here. A lot of new infinite sum polynomial have been found recently. http://www.research.att.com/~njas/sequences/?q=bagula+infinite+sum&sort=0&fm\ t=0&language=english&go=Search These new infinite sum polynomials below come from noticing that (k+1)^n-> Eulerian (2*k+1)^n-> MacMahon Binomial[k,n]--> like the Hanna type were all good Infinite sums of the general 1/(1-x)^n=Sum[f[k,n]*x^k,{k,0,Infinity}] I said to myself that the combinations: (k+1)^n*Binomial[k,n] (2*k+1)^n*Binomial[k,n] were also of that type. I was hoping for something like Eulerian or a MacMahon, but got some sort of higher Stirling like sequence. the StirlingS1[k,n] level is probably fundamental as an Infinite sum as well, but it won't calculate in Mathematica: Clear[p, x, n, m] p[x_, n_] = (1 - x)^(n + 1)*Sum[(-1)^(k + n)*StirlingS1[k, n]*x^k, {k, 0, Infinity}] Table[FullSimplify[ExpandAll[p[x, n]]], {n, 0, 10}] Table[CoefficientList[FullSimplify[ExpandAll[p[x, n]]], x], {n, 0, 10}] Flatten[%] %I A156653 %S A156653 1,1,3,1,16,13,1,125,171,39,1,1296,2551,1091,101,1,16807,43653,28838, %T A156653 5498,243,1,262144,850809,780585,243790,24270,561,1,4782969,18689527, %U A156653 22278189,10073955,1733035,98661,1263,1,100000000,457947691,677785807 %N A156653 Coefficients of a higher level infinite sum polynomial: p(x,n)=(1 - x)^(2n + 1)/((n + 1)*x^n)*Sum[(k + 1)^n*Binomial[k, n]*x^ k, {k, 0, Infinity}]. %C A156653 Roe sums are:A001761; %C A156653 {1, 1, 4, 30, 336, 5040, 95040, 2162160, 57657600, 1764322560, 60949324800,...}. %F A156653 p(x,n)=(1 - x)^(2n + 1)/((n + 1)*x^n)*Sum[(k + 1)^n*Binomial[k, n]*x^ k, {k, 0, Infinity}]; %F A156653 t(n,m)=coefficients(p(x,n)). %e A156653 {1}, %e A156653 {1}, %e A156653 {3, 1}, %e A156653 {16, 13, 1}, %e A156653 {125, 171, 39, 1}, %e A156653 {1296, 2551, 1091, 101, 1}, %e A156653 {16807, 43653, 28838, 5498, 243, 1}, %e A156653 {262144, 850809, 780585, 243790, 24270, 561, 1}, %e A156653 {4782969, 18689527, 22278189, 10073955, 1733035, 98661, 1263, 1}, %e A156653 {100000000, 457947691, 677785807, 410994583, 106215619, 10996369, 379693, 2797, 1}, %e A156653 {2357947691, 12400462713, 22055317500, 17027114412, 6066172434, 976428894, 64468572, 1406460, 6123, 1} %t A156653 Clear[p, x, n, m]; %t A156653 p[x_, n_] = (1 - x)^( 2n + 1)/((n + 1)*x^n)*Sum[(k + 1)^n*Binomial[k, n]*x^k, {k, 0, Infinity}]; %t A156653 Table[FullSimplify[ExpandAll[p[x, n]]], {n, 0, 10}]; %t A156653 Table[CoefficientList[FullSimplify[ExpandAll[p[x, n]]], x], {n, 0, 10}]; %t A156653 Flatten[%] %K A156653 nonn,tabl %O A156653 0,3 %A A156653 Roger L. Bagula (rlbagulatftn(AT)yahoo.com), Feb 12 2009 %I A156654 %S A156654 1,3,1,25,22,1,343,515,101,1,6561,14156,5766,396,1,161051,456197,299342, %T A156654 49642,1447,1,4826809,16985858,15796159,4592764,371239,5090,1,170859375, %U A156654 719818759,878976219,383355555,58474285,2550165,17481,1,6975757441 %N A156654 Coefficients of a higher level infinite sum polynomial: p(x,n)=(1 - x)^(2n + 1)/(x^n)*Sum[(2*k + 1)^n*Binomial[k, n]*x^k, {k, 0, Infinity}]. %C A156654 Roe sums are:A052714; %C A156654 {1, 4, 48, 960, 26880, 967680, 42577920, 2214051840, 132843110400, %C A156654 9033331507200, 686533194547200 %F A156654 p(x,n)=(1 - x)^(2n + 1)/(x^n)*Sum[(2*k + 1)^n*Binomial[k, n]*x^k, {k, 0, Infinity}]; %F A156654 t(n,m)=coefficients(p(x,n)). %e A156654 {1}, %e A156654 {3, 1}, %e A156654 {25, 22, 1}, %e A156654 {343, 515, 101, 1}, %e A156654 {6561, 14156, 5766, 396, 1}, %e A156654 {161051, 456197, 299342, 49642, 1447, 1}, %e A156654 {4826809, 16985858, 15796159, 4592764, 371239, 5090, 1}, %e A156654 {170859375, 719818759, 878976219, 383355555, 58474285, 2550165, 17481, 1}, %e A156654 {6975757441, 34264190872, 52246537948, 31191262504, 7488334150, 660394024, 16574428, 59032, 1}, %e A156654 {322687697779, 1811734208009, 3329783850284, 2563367714324, 872277734234, 126505988606, 6870434876, 103682276, 196811, 1}, %e A156654 {16679880978201, 105414122807918, 227501403350541, 216602727685224, 97632310949922, 20706515546388, 1928212521522, 67389166824, 630891141, 649518, 1} %t A156654 Clear[p, x, n, m]; %t A156654 p[x_, n_] = (1 - x)^(2n + 1)/(x^n)*Sum[(2*k + 1)^n*Binomial[k, n]*x^k, {k, 0, Infinity}]; %t A156654 Table[FullSimplify[ExpandAll[p[x, n]]], {n, 0, 10}]; %t A156654 Table[CoefficientList[FullSimplify[ExpandAll[p[x, n]]], x], {n, 0, 10}]; %t A156654 Flatten[%] %K A156654 nonn,tabl %O A156654 0,2 %A A156654 Roger L. Bagula (rlbagulatftn(AT)yahoo.com), Feb 12 2009 -- Respectfully, Roger L. Bagula 11759Waterhill Road, Lakeside,Ca 92040-2905,tel: 619-5610814 :http://www.geocities.com/rlbagulatftn/Index.html alternative email: rlbagula@sbcglobal.net === Subject: Re: New free introductory book on Mathematica programming, useful. > This is terrific stuff, thank you. > > Peter > > 2009/2/12 Leonid Shifrin : >> >> This is my first post here, although I have been >> a long-term Mathematica user. My field is (more correctly, >> was until recently) Theoretical and Mathematical Physics. >> >> >> I have been using Mathematica for about 12 years now, >> but only the last 4 as a programmer. Being a Mathematica >> enthusiast, I have written an introductory book (well, a >> first part of it) on Mathematica programming based on my >> own experiences and my compilation of existing literature, >> as an expansion of notes-to-self. The motivation was to >> minimize frustration of learning Mathematica programming for >> someone like myself 4 years ago. >> >> My experience is that, for a beginner, it is easiest to learn >> Mathematica (programming) when it is illustrated with many simple >> examples and is as much separated from any field-specific >> application as possible. This is what I tried to do in the >> book. >> >> What I had in mind was a pure programming book about Mathematica >> language, with no reference to any specific field-related >> functionality, with lots of examples being small but complete >> projects, less comprehensive than Mathematica book but containing more >> substantial programs, easier to read than Roman Maeder's books >> (but by no means a substitute), more applied than David Wagner's >> (apart from the fact that it is out of print), going a little deeper \ into >> the language core and being somewhat more pragmatic than >> Paul Wellin et al (please don't get me wrong - these are all excellent >> books), and centered around functional programming layer, main >> higher-order functions, idiomatic Mathematica programming and >> efficiency. >> >> An ideal reader for it would be a person who has some Mathematica >> experience as a user, needs to write programs more substantial >> than a few one-liners, and wants to understand the logic of the >> language and ways to program idiomatically, minimize programming >> effort and maximize program's efficiency. Parts of the book >> (chapters 1-4) can also be useful for more occasional Mathematica >> users, and the last chapter may be of some interest to more >> experienced users as well. >> >> >> I much hope that the book will be not completely useless and >> that I will get some feedback which will help me improve it. If you >> think >> that some material is described inaccurately, or missing, or \ unnecessary, >> or whatever, please let me know! >> >> The book is available for free from my web site, >> >> , >> >> and is published under Creative Commons Non-commercial >> share-alike License. It is possible to read it online or >> download a pdf version. >> >> >> Apart from the book, I have made several tools that I use >> myself and that I believe could be of interest to >> some Mathematica users. I plan to sumbit them to MathSource >> soon, but will appreciate any feedback even before that, >> while they are in \alpha\. >> >> All packages are accompanied by Mathematica notebooks with >> numerous examples of use and explanations of all package's >> features. They have been all tested with v.5.2 and 6.0, >> although perhaps my test suits were too thin. The following >> packages are currently freely available from the same web site, >> : >> >> \ *****************************************************************************\ ************** >> >> - Cache >> >> Creates a cached version of a given function and >> fetches results of frequent function calls from cache >> of a fixed user-defined size. Slower than f[x_]:=f[x]=... >> idiom, but you control the size of DownValues list. Can >> be useful for functions which are at least minimally >> computationally demanding, in unattended computations. >> >> >> - UnsortedOperations >> >> Reasonably fast functions to do various manipulations >> with several lists without sorting, such as mapping >> a function on elements of one list being members of >> another one, unsorted Union, Intersection, Complement, >> etc. This package is an expansion of the last case >> study in the last chapter of the book. >> >> - AttributesOfPureFunctions >> >> Produces new pure functions at run-time, with the >> desired sets of attributes but otherwise the same as >> the original ones. Can also \wrap\ the \normal\ >> (DownValue-based) function into a pure function wrapper, >> with the pure function sharing with the original all >> Attributes that make sense for pure functions. >> >> - CheckOptions >> >> For any user-defined (or modified) DownValue-based >> option-taking function, which uses the ___?OptionQ to >> declare options, adds new definitions that check >> options for validity (not just the option name, but >> also the option's rhs) and can execute arbitrary user- >> defined code upon receiving inappropriate option(s) (such >> as returning $Failed, Throw-ing an exception, etc). >> The limitations are discussed in :Discussion: >> section of the package documentation. >> >> >> >> - PackageOptionChecks >> >> Elevates the functionality of CheckOptions to the level >> of the package(context), while retains the control on >> the level of individual functions as well. Adds an >> easy-to use interface to \protect\ package's functions >> from inappropriate options. Can work from within the >> package of interest, or \externally\ (in the latter case >> no code modifications for the package itself are needed). >> Can be also used for Global` context during interactive >> development (before putting functions into a package). >> Essentially, allows to \meta-program\ the package by >> specifying the response actions for each function after >> (and independently) of the main function's code, and >> gives the user external control over this responding >> behavior. Can also be used as a debugging tool. >> Limitations are discussed in the :Discussion: section of >> the package documentation. >> >> >> - PackageManipulations >> >> Allows to dynamically reload, clear or remove the >> package's context in a way consistent with general >> package mechanics in Mathematica. Useful for interactive >> package development, especially for larger projects with >> many inter-dependent packages. Dynamic re-loader tracks >> escaping symbols and (optionally) can automatically >> resolve possible shadowing problems occuring before or >> during re-loading. >> >> >> - PackageSymbolsDependencies >> >> >> For a given package/context, answers the following >> questions: >> >> 1. Do there exist symbols in other contexts that >> depend on symbols in a given one through some global >> properties (DownValues etc) >> 2. If so, what they are >> 3. For a given arbitrary Mathematica expression, what >> are the symbols used to build it, and their contexts >> 4. Whether or not a given symbol is shadowed >> >> The package is highly customizable, with its efficiency >> depending mainly on how much we know about the set of >> possibly dependent symbols. It can be used to analyze >> inter-context dependencies in larger projects, and to >> discover/monitor modifications that a given package >> induces in other contexts (including overloading system >> functions). This is also a good practical example of >> in action, since options here are >> protected with PackageOptionChecks. >> >> >> \ *****************************************************************************\ ******** >> >> If you intend to use any of these, I will be happy, but please read the >> disclaimer on my web site. If you find bugs in the packages or in the >> book, >> I will also greatly appreciate if you let me know - please see the >> section of my web site. >> >> >> >> >> Leonid Shifrin >> >> >> > === Subject: Re: optimization A simplification u = Array[a, {3, 2}]; MapThread[Equal, {Map[Apply[Plus, #] &, u], Table[1, {Length[u]}]}] == Thread[Total /@ u == 1] True Another simplification largo = Flatten[u]; MapThread[Greater, {largo, Table[0, {Length[largo]}]}] == Thread[largo > 0] True Fix error Flatten[Thread[Total /@ u == 1]; Thread[largo > 0]] {a(1,1)>0,a(1,2)>0,a(2,1)>0,a(2,2)>0,a(3,1)>0,a(3,2)>0} Note that the semi-colon suppresses all of the first expression (i.e., the \ constraints that the rows sum to 1). You intended Join[Thread[Total /@ u == 1], Thread[largo > 0]] Nested tables can be written as a single Table Table[Table[a[k, i], {k, 1, 5}], {i, 1, 3}] == Table[a[k, i], {i, 3}, {k, 5}] True You don't need to Flatten prior to using Total Total[Flatten[u]] == Total[u, 2] True You have a circular definition for u (u defined in terms of u) paso2[individuo_, centro_, m_] := Module[ {largo, a, u}, u = Array[a, {Length[individuo], Length[centro]}]; largo = Flatten[u]; NMinimize[{Total[ Table[ EuclideanDistance[individuo[[k]], centro[[i]]]*u[[k, i]]^m, {i, Length[centro]}, {k, Length[individuo]}], 2], Join[Thread[Total /@ u == 1], Thread[largo > 0]]}, largo]] Bob Hanlon paso2[individuo_,centro_,m_]:=Module[{largo,u=Array[u,{Length[individuo],Len\ gth[centro]}]},largo=Flatten[u];NMinimize[{Total[Flatten[Table[Table[Euclidea\ nDistance[individuo[[k]],centro[[i]]]*u[[k,i]]^m,{k,1,Length[individuo]}],{i,\ 1,Length[centro]}]]], \ Flatten[MapThread[Equal,{Map[Apply[Plus,#]&,u],Table[1,{Length[u]}]}];MapThre\ ad[Greater,{largo,Table[0,{Length[largo]}]}]]},largo]] in Mathematica 7. However, this function is obviously not capturing the restriction that \ u[i,j]+u[i,k]==1For example, u[1,1]+u[1,2] should sum up to 1this restriction \ corresponding to the following piece of code: \ Flatten[MapThread[Equal,{Map[Apply[Plus,#]&,u],Table[1,{Length[u]}]}] === Subject: Re: Reposted, Reformatted Re: \mapping\ functions over l= ists, again! > This is a repost of an earlier post, as there were problems with the \ emai= l > formatting for some people. I have composed this one in Notepad, and cut \ = and > pasted to Outlook. Hope it works better. it does work better :-) > This is a list of lists, the lowest level lists containing pairs of \ {real= , > complex}. The individual lists are not all the same length, and the total > number of lists can vary, and I need to preserve the list structure. > > So I think the most succinct way of expressing my problem is, what form \ d= oes > fxn take if I want to Map it across my lists of {real,complex} so that it > returns {fxn1[real],fxn2[complex]} or even {real,fxn[complex]}? If I understand correctly what you try to achieve I think the easiest solution will be to use replacement only, it will preserve the structure and can be set up to handle the pairs as you want. Basically I see two approaches, which also can be combined. The first one looks simpler, but only works if the structure of your data doesn't change (the sizes of the list of list can of course be arbitrary): Replace[shortTestdata, {r_, c_} :> {f1[r], f2[c]}, {2}] the trick is to restrict the replacement to the correct level. If you are working with data where the level at which the pairs appear can be arbitrary, you can pick the parts to be treated with a more elaborated rule, like this: shortTestdata /. {r_ /; Element[r, Reals],c_ /; Element[c, Complexes]}:> {f1[r], f2[c]} (/. is short for ReplaceAll). This version should work with arbitrary structured lists of arbitrary depths. I think using the Element-Function to decide what kind of number you are looking at is in your case closer to what you want to achieve than to look at the Head, which has some implications, as you have learned from other posts. Finally you could combine the two approaches: Replace[shortTestdata, {r_ /; Element[r, Reals],c_ /; Element[c, Complexes]}:> {f1[r], f2[c]}, {2}] this could make sense if you have a well structured list, but the pairs could be either of the form {reals,reals}, {real,complex}, {complex,complex} and you want to treat these cases differently. You should be aware that other approaches might be faster, but these will for sure be more elaborate and error prone than the code above. hth, albert === Subject: Re: (2/3)[[1]] > Further, in the documentation page for Part, there is no explicit > statement that something for which AtomQ returns True does not have > parts. Still Further, the documentation for AtomQ says that AtomQ[expr] > yields True if expr is an expression which cannot be divided into > subexpressions; If one understands 'a part of an expression' and 'subexpression' as the same thing, I would understand the last part of the second sentence to be just another formulation of the last part of the first. > The situation begs for clarification! Maybe the documentation could be improved, so it doesn't use too many Mathematica specific words which are not clearly defined... hth, albert === Subject: Re: New free introductory book on Mathematica programming, and a \ few Several months ago someone posted the question of why use Mathematica over other software and that he had to make a presentation at his University to convince them to continue with Mathematica.......while looking at Leonard Shifrin's website I noticed that in the appendix of his tutorial there is a section entitled.... \What is so special about Mathematica (a personal evaluation)\..... http://www.mathprogramming-intro.org/book/node66.html I enjoyed reading this and thought it might be valuable to others.... ----- Original Message ----- === Subject: New free introductory book on Mathematica programming, and a few This is my first post here, although I have been a long-term Mathematica user. My field is (more correctly, was until recently) Theoretical and Mathematical Physics. I have been using Mathematica for about 12 years now, but only the last 4 as a programmer. Being a Mathematica enthusiast, I have written an introductory book (well, a first part of it) on Mathematica programming based on my own experiences and my compilation of existing literature, as an expansion of notes-to-self. The motivation was to minimize frustration of learning Mathematica programming for someone like myself 4 years ago. My experience is that, for a beginner, it is easiest to learn Mathematica (programming) when it is illustrated with many simple examples and is as much separated from any field-specific application as possible. This is what I tried to do in the book. What I had in mind was a pure programming book about Mathematica language, with no reference to any specific field-related functionality, with lots of examples being small but complete projects, less comprehensive than Mathematica book but containing more substantial programs, easier to read than Roman Maeder's books (but by no means a substitute), more applied than David Wagner's (apart from the fact that it is out of print), going a little deeper into the language core and being somewhat more pragmatic than Paul Wellin et al (please don't get me wrong - these are all excellent books), and centered around functional programming layer, main higher-order functions, idiomatic Mathematica programming and efficiency. An ideal reader for it would be a person who has some Mathematica experience as a user, needs to write programs more substantial than a few one-liners, and wants to understand the logic of the language and ways to program idiomatically, minimize programming effort and maximize program's efficiency. Parts of the book (chapters 1-4) can also be useful for more occasional Mathematica users, and the last chapter may be of some interest to more experienced users as well. I much hope that the book will be not completely useless and that I will get some feedback which will help me improve it. If you think that some material is described inaccurately, or missing, or unnecessary, or whatever, please let me know! The book is available for free from my web site, , and is published under Creative Commons Non-commercial share-alike License. It is possible to read it online or download a pdf version. Apart from the book, I have made several tools that I use myself and that I believe could be of interest to some Mathematica users. I plan to sumbit them to MathSource soon, but will appreciate any feedback even before that, while they are in \alpha\. All packages are accompanied by Mathematica notebooks with numerous examples of use and explanations of all package's features. They have been all tested with v.5.2 and 6.0, although perhaps my test suits were too thin. The following packages are currently freely available from the same web site, : ************************************************************************* - Cache Creates a cached version of a given function and fetches results of frequent function calls from cache of a fixed user-defined size. Slower than f[x_]:=f[x]=... idiom, but you control the size of DownValues list. Can be useful for functions which are at least minimally computationally demanding, in unattended computations. - UnsortedOperations Reasonably fast functions to do various manipulations with several lists without sorting, such as mapping a function on elements of one list being members of another one, unsorted Union, Intersection, Complement, etc. This package is an expansion of the last case study in the last chapter of the book. - AttributesOfPureFunctions Produces new pure functions at run-time, with the desired sets of attributes but otherwise the same as the original ones. Can also \wrap\ the \normal\ (DownValue-based) function into a pure function wrapper, with the pure function sharing with the original all Attributes that make sense for pure functions. - CheckOptions For any user-defined (or modified) DownValue-based option-taking function, which uses the ___?OptionQ to declare options, adds new definitions that check options for validity (not just the option name, but also the option's rhs) and can execute arbitrary user- defined code upon receiving inappropriate option(s) (such as returning $Failed, Throw-ing an exception, etc). The limitations are discussed in :Discussion: section of the package documentation. - PackageOptionChecks Elevates the functionality of CheckOptions to the level of the package(context), while retains the control on the level of individual functions as well. Adds an easy-to use interface to \protect\ package's functions from inappropriate options. Can work from within the package of interest, or \externally\ (in the latter case no code modifications for the package itself are needed). Can be also used for Global` context during interactive development (before putting functions into a package). Essentially, allows to \meta-program\ the package by specifying the response actions for each function after (and independently) of the main function's code, and gives the user external control over this responding behavior. Can also be used as a debugging tool. Limitations are discussed in the :Discussion: section of the package documentation. - PackageManipulations Allows to dynamically reload, clear or remove the package's context in a way consistent with general package mechanics in Mathematica. Useful for interactive package development, especially for larger projects with many inter-dependent packages. Dynamic re-loader tracks escaping symbols and (optionally) can automatically resolve possible shadowing problems occuring before or during re-loading. - PackageSymbolsDependencies For a given package/context, answers the following questions: 1. Do there exist symbols in other contexts that depend on symbols in a given one through some global properties (DownValues etc) 2. If so, what they are 3. For a given arbitrary Mathematica expression, what are the symbols used to build it, and their contexts 4. Whether or not a given symbol is shadowed The package is highly customizable, with its efficiency depending mainly on how much we know about the set of possibly dependent symbols. It can be used to analyze inter-context dependencies in larger projects, and to discover/monitor modifications that a given package induces in other contexts (including overloading system functions). This is also a good practical example of in action, since options here are protected with PackageOptionChecks. ************************************************************************* If you intend to use any of these, I will be happy, but please read the disclaimer on my web site. If you find bugs in the packages or in the book, I will also greatly appreciate if you let me know - please see the section of my web site. Leonid Shifrin === Subject: Re: NDSolve - Nice function but stiffness-problem UÀytkownik \Nano\ \ napisaÒ w wiadomo\.a6ci ... USE Solve instead DSolve --- this eq. has got an \simple\ analytic \ solution. slawek === Subject: Re: NDSolve - Nice function but stiffness-problem UÀytkownik \slawek\ napisaÒ \ w wiadomo\.a6ci > UÀytkownik \Nano\ \ napisaÒ w wiadomo\.a6ci > ... > > USE Solve instead DSolve --- this eq. has got an \simple\ analytic > solution. USE DSolve instead NDSolve -- correction. === Subject: Re: Problems about \For\ > > I've realized a loop using Euler method: > > For[i=1,i<2, > {S=1/2*N12/DE[i-1]-1/2*DE[i-1]*=83=D5rif2, > a[i]=DSolve[=83=E2'[t]-S=83=FA0,=83=E2[t],t],=83=E2[t]==83=E2[t]/.a[= > i], > =83=E2[t]==83=E2[t]/.C[1]=84_C1, > eq==83=E2[t]/.t=84_(t1[[i]]-1), > =83=E2[i]==83=E2[t]/.{C1=84_a,t=84_t1[[i]]},DE[i]=DE[i-1]*=83=E2[i]}= > ;i++]; > > in this expression, N1 is stated like a sinusoidal function: > N1=N0+B*Sin[=83=E7*t]; > > and T1 is a vector of time: > t1=Table[i,{i,20}]; > > All the other parameters are allocated: > B=1; > N0=2; > =83=E7=1; > A=1; > E0=1; > =83=E2[0]=1; > =83=D5rif=1; > DE[0]=1; > > The loop give me this error: > > Solve::eqf : {-2+C1}=83=FA1 is not a well-formed equation. =83=F7 > with C1 constant of integration. > > > What can I do for this loop in this case and if i want to reapet the > loop for i<100? > Is better to use \DO\? > > > Help me..It's important. > Laura, Your message is unreadable on my different systems (Mac OS X, Windows, and Linux, web browsers Safari, Firefox, or Chrome, or news reader MT-NewsWatcher) for it is crippled by to many non-rendered characters such as =84 or =83=E2. (Of course, other readers might have a different experience.) You should try to copy and past Mathematica expressions in InputForm[], for it is way more readable and far less prone to misinterpretation (especially when your email/newsgroup client adds spurious equal sings and/or other unwanted characters or character conversions). To use the _InputForm_ when copying an expression from a Mathematica notebook to an email client: select the cell(s) you want to include in your email, then within the *Cell* menu select either *Convert To* or *Display As* and choose *InputForm*. Finally, copy and paste as usual. --Jean-Marc === Subject: Re: Conditional evaluations of functions On Feb 15, 3:21 am, Jean-Marc Gulliet > > > I am not sure why the function g does not work, but the function f > > works as expected on Mathematica 7.0 on Windows XP. I want to get th= e > > sum of a vector only if the argument supplied is a numeric vector. > > > In[1]:= g[x_?VectorQ[ x, NumericQ]] := Total[x] > > > In[2]:= g[{a, b , c}] > > > Out[2]= g[{a, b, c}] > > > In[3]:= g[{1, 2, 3}] > > > Out[3]= g[{1, 2, 3}] > > > The test function that follows the question mark operator '?' is > expected to be a pure function. A *pattern*, like the one used for the > function f after the condition operator '/;' (which expect a pattern) is > *not* a pure function. Try > > In[1]:= > > g[(x_)?(VectorQ[#1, NumericQ] & )] := Total[x] > g[{a, b, c}] > g[{1, 2, 3}] > > Out[2]= g[{a, b, c}] > > Out[3]= 6 > > --Jean-Marc document that one needs a Pure Function. Asim === Subject: Try again to send my message: problems about \for\ the last message was unreadable and so i send it again. I've realized a loop using Euler method: For[i = 1, i < 2, {S = (1/2)*(N1^2/DE[i - 1]) - (1/2)*DE[i - 1]*\\[Epsilon]rif^2, a[i] = DSolve[Derivative[1][\\[Rho]][t] - S == 0, \\[Rho][t], t], \\[Rho][t] = \\[Rho][t] /. a[i], \\[Rho][t] = \\[Rho][t] /. C[1] -> C1, eq = \\[Rho][t] /. t -> (t1[[i]] - 1), a = Solve[eq == \\[Rho][i - 1], C1], \\[Rho][i] = \\[Rho][t] /. {C1 -> a, t -> t1[[i]]}, DE[i] = DE[i - 1]*\\[Rho][i]}; i++]; in this expression, N1 is stated like a sinusoidal function: N1 = N0 + B*Sin[\\[Omega]*t]; and T1 is a vector of time: t1 = Table[i, {i, 20}] All the other parameters are allocated: B = 1; N0 = 2; \\[Omega] = 1; A = 1; E0 = 1; \\[Rho][0] = 1; \\[Epsilon]rif = 1; The loop give me this error: Solve::eqf:{-2+C1}==1 is not a well-formed equation. >> with C1 constant of integration. What can I do for this loop in this case and in a case if i want to reapet the loop for i<100? Is better to use \DO\? Help me..It's important. === Subject: Re: Try again to send my message: problems about \for\ Hi Laura, curly bracket are used to denote lists not bracketing, you must use \(..)\ for bracketing. Therefore \{-2+C1}==1\ is not an equation. Then, the function DE is not defined. Further, a compound statement uses \;\ as delimiter, not \,\. There is no {..} needed inside the For loop: Fot[ ..; ..; ... ,++i] hope this helps, Daniel > the last message was unreadable and so i send it again. > > > I've realized a loop using Euler method: > For[i = 1, i < 2, > {S = (1/2)*(N1^2/DE[i - 1]) - (1/2)*DE[i - 1]*\\[Epsilon]rif^2, > a[i] = DSolve[Derivative[1][\\[Rho]][t] - S == 0, \\[Rho][t], t], > \\[Rho][t] = \\[Rho][t] /. a[i], > \\[Rho][t] = \\[Rho][t] /. C[1] -> C1, > eq = \\[Rho][t] /. t -> (t1[[i]] - 1), > a = Solve[eq == \\[Rho][i - 1], C1], > \\[Rho][i] = \\[Rho][t] /. {C1 -> a, t -> t1[[i]]}, > DE[i] = DE[i - 1]*\\[Rho][i]}; i++]; > > in this expression, N1 is stated like a sinusoidal function: > N1 = N0 + B*Sin[\\[Omega]*t]; > > and T1 is a vector of time: > t1 = Table[i, {i, 20}] > > All the other parameters are allocated: > B = 1; > N0 = 2; > \\[Omega] = 1; > A = 1; > E0 = 1; > \\[Rho][0] = 1; > \\[Epsilon]rif = 1; > > The loop give me this error: > Solve::eqf:{-2+C1}==1 is not a well-formed equation. >> > > with C1 constant of integration. > > > What can I do for this loop in this case and in a case if i want to > reapet the loop for i<100? > Is better to use \DO\? > > > Help me..It's important. > > === Subject: Printing large symbolic matrices The answer to some of my course homeworks in Mathematica are symbolic matrices, and often the MatrixForm print exceeds the print width (6.5\ in A size). On the screen one can stroll but that is not available for print output. Is there a way to specify a maximum # of columns-per-pagewidth directly to the Print command, to get automatic column wrap? === Subject: Re: reference to cite for ProteinData[] OK...It appears these \columns\ from ProteinData[], such as CellularComponents and MolecularFunctions comes from entries in UniProtKB which comes from GeneOntology. For the protein listed below, this is shown here: http://www.uniprot.org/uniprot/O95477#section_terms. I would hope that this explanation can be confirmed or corrected and updated in the Help Browser. > Hello MathGroup: > > Does anyone know where this data comes from? Specifically, when I type > the following: > > ProteinData[\ABCA1\, \BiologicalProcesses\][[8]] > > Mathematica emits: > > IntracellularCholesterolTransport > > This protein lists many other processes as well. Is there anyway I can > confirm this result? > > Roger Williams > Franklin Laboratory === Subject: coloring of proteins when using Import[] from PDB Hello MathGroup: If anyone can tell me how the Import[] command decides how to color proteins I am interested in this. An example is: Import[\http://www.genome.ad.jp/dbget-bin/www_bget?pdb+1THJ+withATOM\, \PDB\] This is a trimer called \gamma\-Carbonic Anhydrase. In the book I am working from (i.e. BiochemistryV6 by Stryer p.259), the coloring reflects the trimeric structure. In the rendering from Import[], all three alpha-helices have the same color for example. TIA. Roger Williams Franklin Laboratory === Subject: Why does Derivative fail in this case? This example is self-explanatory: f[x_, y_] := x y g = f[##]*f[##] &; h = Derivative[1, 0][g]; g[x, y] h[x, y] I should expect that h[x, y] is 2 x y^2, but instead it is zero. How come? Version 6.0 Aaron === Subject: Re: Why does Derivative fail in this case? try: g = f[#1, #2]*f[#1, #2] &; And why SlotSequence[1] is different from Slot[1] is self-explanatory Jens > > This example is self-explanatory: > > f[x_, y_] := x y > g = f[##]*f[##] &; > h = Derivative[1, 0][g]; > g[x, y] > h[x, y] > > I should expect that h[x, y] is 2 x y^2, but instead it is zero. How > come? > > Version 6.0 > > > Aaron > === Subject: Re: Why does Derivative fail in this case? This works: f[x_, y_] := x y g = f[##]*f[##] &; h[x_, y_] := D[g[x, y], x] g[x, y] h[x, y] x^2 y^2 2 x y^2 As to why the other did not? Not sure. I do know it's often a poor idea to write functions without arguments. Bobby > > This example is self-explanatory: > > f[x_, y_] := x y > g = f[##]*f[##] &; > h = Derivative[1, 0][g]; > g[x, y] > h[x, y] > > I should expect that h[x, y] is 2 x y^2, but instead it is zero. How > come? > > Version 6.0 > > > Aaron > -- DrMajorBob@longhorns.com === Subject: Re: Why does Derivative fail in this case? Hi Aaron, if you write: g = f[##]*f[##] &; the number of arguments to f is not defined until you execute g, specifying arguments. g alone will not evaluate. Therefore g is treated as a constant in: Derivative[1, 0][g1]. As a remedy, spezify the arguments in: g1 = f1[#1, #2]^2 &; and all is well. hope this helps, Daniel > > This example is self-explanatory: > > f[x_, y_] := x y > g = f[##]*f[##] &; > h = Derivative[1, 0][g]; > g[x, y] > h[x, y] > > I should expect that h[x, y] is 2 x y^2, but instead it is zero. How > come? > > Version 6.0 > > > Aaron > === Subject: Re: Why does Derivative fail in this case? > f[x_, y_] := x y > g = f[##]*f[##] &; > h = Derivative[1, 0][g]; > g[x, y] > h[x, y] > I should expect that h[x, y] is 2 x y^2, but instead it is zero. How > come? You've written g so that it's a function of SlotSequence[1] (which is what FullForm[##1] will give you), while Derivative[1,0][g] effectively takes the derivative with respect to Slot[1] (a.k.a. #1). Writing g = f[#1,#2] * f[#1,#2] &; will do what you want. Pillsy === Subject: Re: How to stretch a image > such as the size of a image is 100 x 100, I want to make it stretch to > 200 x 600 (not 1:1). Mathematica give me 200x200 +200x400 blank. I tried > Padding and Margins, no working : ( > > PS, in Mathematica 6. Well, with Mathematica 7.0 this is really straightforward since V7 many new function specially designed for image processing [1]. For instance, img = Import[\ExampleData/rose.gif\] ImageResize[img, {200, 600}] You could check the Wolfram Demonstrations Project, which contains many applications about image processing, though quite a lot of them seems t use extensively Mathematica V7's new features [2]. Sorry for not being more helpful, --Jean-Marc [1] \Image Processing & Analysis\ http://reference.wolfram.com/mathematica/guide/ImageProcessing.html [2] \Wolfram Demonstrations Project\ http://demonstrations.wolfram.com/search.html?query=topics%3Aimage+proces sing+content%3AArrayPlot+OR+CellularAutomaton+OR+ColorFunction+OR+ColorRu les+OR+Export+OR+Fourier+OR+FourierDCT+OR+FourierDST+OR+Import+OR+ListCon volve+OR+Pick+OR+Rasterize+OR+ReliefPlot&start=1&limit === Subject: Re: How to stretch a image you may e.g. use ApsectRatio and ImageSize. E.g. try: Import[\ExampleData/lena.tif\, AspectRatio -> 0.5, ImageSize -> 1000] hope this helps, Daniel > such as the size of a image is 100 x 100, I want to make it stretch to > 200 x 600 (not 1:1). Mathematica give me 200x200 +200x400 blank. I tried > Padding and Margins, no working : ( > > PS, in Mathematica 6. > === Subject: Re: How to stretch a image if you don't care about the lausy reconstruction filter img = Import[\http://blog.wolfram.com/images/people/sw.jpg\]; img2 = Rasterize[ img /. Graphics[Raster[bm_, r_, any___], more1___, ImageSize -> _, more2___] :> Graphics[Raster[bm, {{0, 0}, {600, 400}}, any], PlotRange -> All, AspectRatio -> 1/3, more1, more2, ImageSize -> {600, 200}, PlotRangePadding -> {0, 0}]] Jens > such as the size of a image is 100 x 100, I want to make it stretch to > 200 x 600 (not 1:1). Mathematica give me 200x200 +200x400 blank. I tried > Padding and Margins, no working : ( > > PS, in Mathematica 6. > === Subject: Re: How to stretch a image >such as the size of a image is 100 x 100, I want to make it stretch to >200 x 600 (not 1:1). Mathematica give me 200x200 +200x400 blank. I tried >Padding and Margins, no working : ( > >PS, in Mathematica 6. Use the AspectRatio option with the ImageSize option to stretch the image to the desired dimensions: With[{w = 200, h = 600}, Graphics[Disk[], AspectRatio -> h/w, ImageSize -> {w, h}]] Chris Hill Wolfram Research === Subject: Re: Functions inside modules with external definitions Jens, I use Module[] because the definition of f[] is inside a Module with a lot of dynamic stuff (say 200 lines of code); and f[] (and other function definitions, local to the module, are the root of all the dynamic \ treatment. I never thought of Block as a construct or \container\ for dynamic \ programs. But maybe I was wrong. Well, I tried many other approaches before posting but I did want to mess \ up the example with other details. I will review the other answers I have had, see what happens, and prepare a full feedback if necessary. But, please, I would appreciate your remarks to this as your solution works as needed. (Although, inside Block[]). Emilio. -----Original Message----- === Subject: Re: Functions inside modules with external definitions and my question is \Why do you use Module[] ?\ expression = a x^c + b y^(1 - c); mx = Block[{f, expression = expression}, f[x_: x, y_: y][a_ : a, b_: b, c_: c] := Evaluate@expression; f[k1, k2][.2, .3, .4] ] work as expected. Jens > > > > Please review the following and see weather my question has and deserves an > answer. It is a about defining functions local to modules but using external > definitions of the right hand side of the local function and passed as > parameters to the module. > > > > > > expression = a x ^c + b y ^(1-c) (* or whatever expression *) > > > > Clear[f]; > > > > f[x_: x,y_: y][a_: a,b_: b,c_: c]:=Evaluate@expression > > > > ?f > > f[k1,k2][.2,.3,.4] > > > > (* Functions inside modules where the RHS of the function has been assigned > to a variable *) > > (* first form works as I expected, but uses an extrenal definition for a > local function (the name is local) *) > > > > m1= > > Module[{f}, > > f[x_: x,y_: y][a_ :a,b_: b,c_: c]:=Evaluate@expression; > > f[k1,k2][.2,.3,.4] > > ] > > > > (* second form. I expected it worked as the one above but it does not; the > expression formed outside is assigned to a local variable with the same name > *) > > > > m2 = > > Module[{f, expression = expression}, > > f[x_: x, y_: y][a_ :a,b_: b,c_: c]:=Evaluate@expression; > > f[k1,k2][.2,.3,.4] > > ] > > > > (* third form. I expected it worked as the first one above but it does not; > the expression is assigned directly to a local variable *) > > > > m3 = > > Module[{f,expression = a x ^c + b y ^(1-c)}, > > f[x_: x,y_: y][a_ :a,b_: b,c_: c]:=Evaluate@expression; > > f[k1,k2][.2,.3,.4] > > ] > > > > (* fourth form. I expected it worked as the first one above but it does not; > the expression is assigned within the body of the module o a local variable > *) > > > > m4 = > > Module[{f,expr}, > > expr =expression; > > f[x_: x,y_: y][a_ :a,b_: b,c_: c]:=Evaluate@expr; > > f[k1,k2][.2,.3,.4] > > ] > > > > (* My question is how to construct a function inside a module in manner > similar to the following *) > > > > expression = a x ^c + b y ^(1-c); > > mx = > > Module[{f,expression = expression}, > > f[x_: x,y_: y][a_ :a,b_: b,c_: c]:=Evaluate@expression; > > f[k1,k2][.2,.3,.4] > > ] > > > > (* and working as the following works *) > > > > m1= > > Module[{f}, > > f[x_: x,y_: y][a_ :a,b_: b,c_: c]:=Evaluate@expression; > > f[k1,k2][.2,.3,.4] > > ] > > > > > > > > > E. martin-Serrano > > === Subject: Re: newbie here,, need help with parametrics Load AccelerationDueToGravity from the PhysicalConstants package, and Convert from the Units package: Needs[\PhysicalConstants`\] Needs[\Units`\] Calculate g in ft/sec^2 (with units removed): g = Convert[AccelerationDueToGravity, Foot/Second^2]/(Foot/Second^2) 196133/6096 (AccelerationDueToGravity is in meters/sec^2.) Define the {x, y} coordinates at time t: r[a_, x_, y_, v_][t_] = {x + t v Cos@a, y + t v Sin@a - 1/2 g t^2} {x + t v Cos[a], -((196133 t^2)/12192) + y + t v Sin[a]} Plot the curve: ParametricPlot[r[30. Degree, 0, 32, 32][t], {t, 0, 2}, PlotRange -> All] Here's a general solution for y == 0: Solve[0 == Last@r[a, x, y, v][t], {t}] {{t -> (4 (1524 v Sin[a] - Sqrt[762] Sqrt[196133 y + 3048 v^2 Sin[a]^2]))/196133}, {t -> ( 4 (1524 v Sin[a] + Sqrt[762] Sqrt[196133 y + 3048 v^2 Sin[a]^2]))/ 196133}} The second solution is the one you need, as the example shows: Solve[0 == Last@r[30. Degree, 0, 32, 32][t], {t}] tDrop = t /. Last@% {{t -> -0.998192}, {t -> 1.99278}} 1.99278 How far did the projectile travel horizontally? r[30. Degree, 0, 32, 32][tDrop] {55.2256, 0.} About 55 feet. Bobby > I am using Mathematica and i'd rather be using derive,,,,, but > anyways,, heres the problem i have to do, a baseball is thrown from the \ > stands 32 feet from the ground at an angle of 30 degrees above the > horizontal, initial velocity is 32 feet per second. > > what i want to do is find how to plot this in mathematica,, the graph i > keep getting says it hits the ground after .8 seconds, and i know > thats not right,,, here is the formula i am using > > r = (x + v Cos a) t) i + (y + (v Sin a) t - 1/2 gt^2) j > > where x is the initial x position and y is the initial height, v is the > initial velocity a is the angle (30*) t is time and g is the > gravitational constant.. > > i'm stuck,,, any help? > -- DrMajorBob@longhorns.com === Subject: Re: newbie here,, need help with parametrics > I am using Mathematica and i'd rather be using derive,,,,, but anyways,, \ heres the problem i have to do, a baseball is thrown from the stands 32 feet \ from the ground at an angle of 30 degrees above the horizontal, initial \ velocity is 32 feet per second. > > what i want to do is find how to plot this in mathematica,, the graph i \ keep getting says it hits the ground after .8 seconds, and i know thats not \ right,,, here is the formula i am using > > r = (x + v Cos a) t) i + (y + (v Sin a) t - 1/2 gt^2) j > > where x is the initial x position and y is the initial height, v is the \ initial velocity a is the angle (30*) t is time and g is the gravitational \ constant.. > > i'm stuck,,, any help? Your equation doesn't have balanced parentheses. If you had posted your actual Mathematica code, then we would know what you did wrong. Since you didn't, we can only guess. My guess is that you gave the angle as \30\, which means 30 radians, instead of \30 Degree\ or \Pi/6\ which would mean 30 degrees. An angle of 30 radians would mean a throw which is almost straight down, so it would take less than a second to cover the 32 foot vertical distance with an initial velocity of 32 feet/sec. Scott -- Scott Hemphill hemphill@alumni.caltech.edu \This isn't flying. This is falling, with style.\ -- Buzz Lightyear === Subject: Re: Laplace Transform Exponential Shift > > >>>InverseLaplaceTransform[Exp[a s],s,t] > >>>is returned unevaluated! > >>in V.7 this seems to work, returns 1/(t-a) > > Hmm... Perhaps there is a platform dependency? On my system > > (Out[6]= 7.0 for Mac OS X x86 (64-bit) (November 11, 2008)) > > InverseLaplaceTransform[Exp[a s],s,t] > > is returned unevaluated That's really strange. I just checked again and it returned unevaluated. But I wouldn't have posted it, if it didn't evaluate right the first time. 7.0 for Mac OS X PowerPC (32-bit) (November 10, 2008) GruÌÄ Peter -- _________________________________________________________ Peter Breitfeld, Bad Saulgau --- http://www.pBreitfeld.de === Subject: Re: Laplace Transform Exponential Shift > > > >>InverseLaplaceTransform[Exp[a s],s,t] > > >>is returned unevaluated! > > >in V.7 this seems to work, returns 1/(t-a) > > Hmm... Perhaps there is a platform dependency? On my system > > (Out[6]= 7.0 for Mac OS X x86 (64-bit) (November 11, 2008)) > > InverseLaplaceTransform[Exp[a s],s,t] > > is returned unevaluated On my Win32 V7.0 too: In[1]:= InverseLaplaceTransform[Exp[a s], s, t] Out[1]= InverseLaplaceTransform[E^(a s), s, t] In[2]:= {$Version, $ReleaseNumber} Out[2]= {\7.0 for Microsoft Windows (32-bit) (November 10, 2008)\, 0} In[1]:= InverseLaplaceTransform[Exp[a s], s, t] Out[1]= InverseLaplaceTransform[E^(a s), s, t] In[2]:= {$Version, $ReleaseNumber} Out[2]= {\6.0 for Mac OS X x86 (64-bit) (May 21, 2008)\, 3} --Jean-Marc === Subject: Division by zero, despite strong hint I'm trying to plot the Sin[1/x] curve with the curve being defined as 0 at 0 like this: g3[x_] := Piecewise[{{Sin[1/x], x != 0} {0, x == 0}}] Invoking Plot produced a flat graph; puzzled I asked for g3[0] and got: Power::infy Infinite expression 1/0 encountered >> { {Indeterminate, False True}, {0, \\!\\(\\* TagBox[\True\, \PiecewiseDefault\, AutoDelete->False, DeletionWarning->True]\\)} } Hmmm... what's the trick here to stop Mathematica evaluating all the \ branches of the piecewise fn? There's nothing in the documentation that I can see to stop this in Piecewise... perhaps I need to use a different \ Mathematica function? David. === Subject: Re: Division by zero, despite strong hint > I'm trying to plot the Sin[1/x] curve with the curve being defined as > 0 at 0 like this: > g3[x_] := Piecewise[{{Sin[1/x], x != 0} {0, x == 0}}] > Hmmm... what's the trick here to stop Mathematica evaluating all the > branches of the piecewise fn? You're missing a comma between the two clauses. Pillsy === Subject: Re: Division by zero, despite strong hint > > > I'm trying to plot the Sin[1/x] curve with the curve being defined as > > 0 at 0 like this: > > g3[x_] := Piecewise[{{Sin[1/x], x != 0} {0, x == 0}}] > > Hmmm... what's the trick here to stop Mathematica evaluating all the > > branches of the piecewise fn? > > You're missing a comma between the two clauses. > > Pillsy A big THANK YOU to everyone that spotted my 'schoolboy' error ;-) I'm old enough to avoid this kind of thing! Or perhaps it's an early onset of senility ;-) === Subject: Re: Division by zero, despite strong hint You left out a comma. g3[x_] := Piecewise[{{Sin[1/x], x != 0} , {0, x == 0}}] Plot[g3[x], {x, -.1, .1}] Help indicates that the routine evaluates the conditions first, without evaluating the expressions, and picks the first condition that is true. Also, it is possible in Plot that the value 0 was never used. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I'm trying to plot the Sin[1/x] curve with the curve being defined as 0 at 0 like this: g3[x_] := Piecewise[{{Sin[1/x], x != 0} {0, x == 0}}] Invoking Plot produced a flat graph; puzzled I asked for g3[0] and got: Power::infy Infinite expression 1/0 encountered >> { {Indeterminate, False True}, {0, \\!\\(\\* TagBox[\True\, \PiecewiseDefault\, AutoDelete->False, DeletionWarning->True]\\)} } Hmmm... what's the trick here to stop Mathematica evaluating all the branches of the piecewise fn? There's nothing in the documentation that I can see to stop this in Piecewise... perhaps I need to use a different Mathematica function? David. === Subject: Re: Division by zero, despite strong hint Hi David, you have a syntax error. There is a comma missing in the definition of the piecewise function. Daniel > > I'm trying to plot the Sin[1/x] curve with the curve being defined as > 0 at 0 like this: > > g3[x_] := Piecewise[{{Sin[1/x], x != 0} {0, x == 0}}] > > Invoking Plot produced a flat graph; puzzled I asked for g3[0] and > got: > > Power::infy Infinite expression 1/0 encountered >> > > { > {Indeterminate, False True}, > {0, \\!\\(\\* > TagBox[\True\, > \PiecewiseDefault\, > AutoDelete->False, > DeletionWarning->True]\\)} > } > > Hmmm... what's the trick here to stop Mathematica evaluating all the \ branches > of the piecewise fn? There's nothing in the documentation that I can > see to stop this in Piecewise... perhaps I need to use a different \ Mathematica > function? > > David. > === Subject: Re: Division by zero, despite strong hint > > I'm trying to plot the Sin[1/x] curve with the curve being defined as > 0 at 0 like this: > > g3[x_] := Piecewise[{{Sin[1/x], x != 0} {0, x == 0}}] > > Hmmm... what's the trick here to stop Mathematica evaluating all the \ branches > of the piecewise fn? There's nothing in the documentation that I can > see to stop this in Piecewise... perhaps I need to use a different \ Mathematica > function? I think you are just missing a comma, the following works as expected: g3[x_] := Piecewise[{{Sin[1/x], x != 0}, {0, x == 0}}] note that 0 is the default output anyway, so this will give the same results: g4[x_] := Piecewise[{{Sin[1/x], x != 0} }] hth, albert === Subject: Re: linear regression with errors in both variables > > I want to test the hypothesis that my data > follows a known simple linear relationship, > y = a + bx. However, I have (known) measurements > errors in both the y and the x values. > > I suppose just a simple linear regression > does not do here. > > Any suggestions how do test this correctly? > > > joerg Hi all, The classic \errors-in-variables\ problem in econometrics has the following structure: (1) yt = a + b*zt + et The paramters of interest are (a, b). The problem is that we don't observe zt. Instead we observe xt which equals zt plus a measurement error: (2) xt = zt + ut In order to proceed, we need to model the unobserved zt. Let (3) zt = m + vt Assume (et, ut, vt) are iid N(0, V) where V = diag(se^2, su^2, sv^2). Integrating zt out of (1-3) using Integrate[ PDF[NormalDistribution[a + b*zt, se], yt] * PDF[NormalDistribution[zt, su], xt] * PDF[NormalDistribution[m, sv], zt], {zt, -Infinity, Infinity}, GenerateConditions -> False] produces (after rearrangement) (4) PDF[NormalDistribution[a1 + b1*xt, se1], yt] * PDF [NormalDistribution[m, su1], xt] which can be expressed as (5) yt = a1 + b1*xt + e1t (6) xt = m + u1t where (7) a1 = a + b*m*su^2/(su^2+sv^2) (8) b1 = b*sv^2/(su^2+sv^2) (9) se1^2 = se^2 + b^2*su^2*sv^2/(su^2+sv^2) (10) su1^2 = su^2+sv^2 The likelihood for the parameters, theta = (a,b,m,se,su,sv), is given by likelihood = Product[fun[data[[t]]], {t, T}] where data is a list of the observed {xt, yt} pairs and fun[{xt, yt}] is given by (4) using the substitutions (7-10). A Bayesian approach specifies a prior distribution for theta, p (theta), and then uses an MCMC algorithm (such as the random-walk Metropolis algorithm) to draw from the posterior distribution, p(theta| data). [The posterior distribution is proportional to likelihood * p (theta).] Note that (xt, yt) has a bivariate normal distribution, which is characterized by 5 parameters. However, there are 6 parameters in theta; this suggests a lack of identification. Fortunately, this presents no particular problem for the Bayesian approach, even with a flat prior for theta. --Mark === Subject: Howto change TraditionalForm Output Hi x_ In some (IMHO mainly European) countries, there is tradition to use other names of the function then are these used in american English. For example here in Czech Republic we use \tg\ and \cotg\ in place of \tan\ and \ \cot\. I'm trying to modify the behaviour of M7 like this: Unprotect[Tan]; Format[Tan[x_], TraditionalForm] := \tg(\ <> ToString[x] <> \)\; Protect[Tan] ; It seems to work fine in the cases: TraditionalForm[Tan[a + b]] TraditionalForm[Tan[z]] TraditionalForm[Tan[Pi]/5] but it doesn't work in case like: TraditionalForm[Tan[z/5]] Does anybody know what is the right syntax to change the Format of TraditionalForm? Thx in advance Jakub === Subject: Re: Howto change TraditionalForm Output Unprotect[Tan] Tan /: MakeBoxes[Tan[a_], TraditionalForm] := RowBox[{\tg\, \(\, ToBoxes[a, TraditionalForm], \)\}] Protect[Tan] Jens > Hi x_ > > In some (IMHO mainly European) countries, there is tradition to use other > names of the function then are these used in american English. For \ example > here in Czech Republic we use \tg\ and \cotg\ in place of \tan\ and \ \cot\. > > I'm trying to modify the behaviour of M7 like this: > > Unprotect[Tan]; > Format[Tan[x_], TraditionalForm] := \tg(\ <> ToString[x] <> \)\; > Protect[Tan] ; > > It seems to work fine in the cases: > > TraditionalForm[Tan[a + b]] > TraditionalForm[Tan[z]] > TraditionalForm[Tan[Pi]/5] > > but it doesn't work in case like: > > TraditionalForm[Tan[z/5]] > > Does anybody know what is the right syntax to change the Format of > TraditionalForm? > > Thx in advance > > Jakub > === Subject: Re: Howto change TraditionalForm Output > In some (IMHO mainly European) countries, there is tradition to use other > names of the function then are these used in american English. For \ example > here in Czech Republic we use \tg\ and \cotg\ in place of \tan\ and \ \cot\. > > I'm trying to modify the behaviour of M7 like this: > > Unprotect[Tan]; > Format[Tan[x_], TraditionalForm] := \tg(\ <> ToString[x] <> \)\; > Protect[Tan] ; > > It seems to work fine in the cases: > > TraditionalForm[Tan[a + b]] > TraditionalForm[Tan[z]] > TraditionalForm[Tan[Pi]/5] > > but it doesn't work in case like: > > TraditionalForm[Tan[z/5]] > > Does anybody know what is the right syntax to change the Format of > TraditionalForm? I'm not sure whether this is still a recommended way to do it with all the higher level functions available for version >= 6, but the following should work, even with versions < 6: Unprotect[Tan]; Format[Tan[x_], TraditionalForm] := DisplayForm[RowBox[{ \tg\, \(\, ToBoxes[x], \)\}]]; Protect[Tan]; If you wonder what all this is about, you might want to learn about the two dimensional formatting via boxes, some entry points for that can be found in the documentation: tutorial/TextualInputAndOutputOverview hth, albert === Subject: Re: Howto change TraditionalForm Output Unprotect[Tan]; Format[Tan[x_], TraditionalForm] := \tg(\ <> ToString[TraditionalForm[x]] <> \)\; Protect[Tan]; Bob Hanlon Hi x_ In some (IMHO mainly European) countries, there is tradition to use other names of the function then are these used in american English. For example here in Czech Republic we use \tg\ and \cotg\ in place of \tan\ and \ \cot\. I'm trying to modify the behaviour of M7 like this: Unprotect[Tan]; Format[Tan[x_], TraditionalForm] := \tg(\ <> ToString[x] <> \)\; Protect[Tan] ; It seems to work fine in the cases: TraditionalForm[Tan[a + b]] TraditionalForm[Tan[z]] TraditionalForm[Tan[Pi]/5] but it doesn't work in case like: TraditionalForm[Tan[z/5]] Does anybody know what is the right syntax to change the Format of TraditionalForm? Thx in advance Jakub === Subject: Re: Logarithmic Plot I do not agree with this classification at all. I am very grateful that people in the math group answer my stupid questions. \ Indeed, sometimes I did not use the help function. And the so called \same \ responses\: I look into them and I often wonder how different they are from \ my own thinking. I learn a lot from these responses. Reading the math group is very useful, for me at least. Of course, sometimes \ one can read \homework' in questions. But nevertheless: I get an impresssion \ of what is going on. with friendly greetings, P_ter === Subject: Re: newbie here,, need help with parametrics === Subject: Re: Log[]//TraditionalForm > PS: I found that Mathematicas performance in general increases a lot > when using the option Brain -> On for $User. I'm not sure whether the > user installed on your system supports that option, but most users do, > so I would give it a try. I am not sure that this is such a good advice. This option has been present since version 1 of Mathematica but its default setting has always been Automatic. I believe that in the early days there was a heated debate at Wolfram whether the default should be changed to On, but it was disovered that the working of this option was very dependent on user architecture and in certain cases setting it to On could lead to unpredictable behaviour, sometimes dangerous the user, his computer and anyone who happened to be in the vicinity. So in order to avoid possible legal problems WRI decided keep Automatic as the default. Andrzej Kozlowski === Subject: Re: Log[]//TraditionalForm > It is very very simple, Lui, you should practise yourself. :) > > BTW, Log vs. ln is an aesthetic problem. The serious troubles are caused \ by > CForm and FortranForm. These \forms\ produces output unreadable by > compilers. Therefore it is not possible to use Mathematica to generate > source code in C language. You need a proof? Here is an example: > > In[1]:= Series[Sin[x],{x,0,5}] > Out[1]= x-x^3/6+x^5/120+O[x]^6 > In[2]:= Series[Sin[x],{x,0,5}]//CForm > Out[2]//CForm= > SeriesData(x,0,List(1,0,-0.16666666666666666,0,0.008333333333333333),1, > 6,1) > In[3]:= Series[Sin[x],{x,0,5}]//FortranForm > Out[3]//FortranForm= > SeriesData(x,0,List(1,0,-0.16666666666666666,0, > - 0.008333333333333333),1,6,1) > > Neither C/C++ nor Fortran (II/IV/77/95) have got \List\ or \ \SeriesData\. If you want something not to work, there are many possibilities to make it fail. The documentation states clearly that only some standard stuff will be translated and you might need some additional definitions. This will work with most compilers I know, provided x is defined as float or double and you include mdefs.h for the C code: Series[Sin[x], {x, 0, 5}] // Normal // CForm Series[Sin[x], {x, 0, 5}] // Normal // FortranForm albert PS: I found that Mathematicas performance in general increases a lot when using the option Brain -> On for $User. I'm not sure whether the user installed on your system supports that option, but most users do, so I would give it a try. === Subject: Re: optimization it is a perfect example of the reason why this list is so useful.If he cost \ is a little bit of noise, it is quite low with respect to the benefits.Fg === Subject: optimization A simplification u = Array[a, {3, 2}]; Thread[Total /@ u == 1] True Another simplification largo = Flatten[u]; MapThread[Greater, {largo, Table[0, {Length[largo]}]}] == Thread[largo > 0] True Fix error Flatten[Thread[Total /@ u == 1]; Thread[largo > 0]] {a(1,1)>0,a(1,2)>0,a(2,1)>0,a(2,2)>0,a(3,1)>0,a(3,2)>0} Note that the semi-colon suppresses all of the first expression (i.e., the constraints that the rows sum to 1). You intended Join[Thread[Total /@ u == 1], Thread[largo > 0]] Nested tables can be written as a single Table Table[Table[a[k, i], {k, 1, 5}], {i, 1, 3}] == Table[a[k, i], {i, 3}, {k, 5}] True You don't need to Flatten prior to using Total Total[Flatten[u]] == Total[u, 2] True You have a circular definition for u (u defined in terms of u) paso2[individuo_, centro_, m_] := Module[ {largo, a, u}, u = Array[a, {Length[individuo], Length[centro]}]; largo = Flatten[u]; NMinimize[{Total[ Table[ EuclideanDistance[individuo[[k]], centro[[i]]]*u[[k, i]]^m, {i, Length[centro]}, {k, Length[individuo]}], 2], Join[Thread[Total /@ u == 1], Thread[largo > 0]]}, largo]] Bob Hanlon paso2[individuo_,centro_,m_]:=Module[{largo,u=Array[u,{Length[individuo= ],Length[centro]}]},largo=Flatten[u];NMinimize[{Total[Flatten[Table[Table= [EuclideanDistance[individuo[[k]],centro[[i]]]*u[[k,i]]^m,{k,1,Length[indiv=\ iduo]}],{i,1,Length[centro]}]]], \ Flatten[MapThread[Equal,{Map[Apply[Plus,#]= &,u],Table[1,{Length[u]}]}];MapThread[Greater,{largo,Table[0,{Length[largo]=\ }]}]]},largo]] in Mathematica 7. However, this function is obviously not capturing the restriction that \ u[i,= j]+u[i,k]==1For example, u[1,1]+u[1,2] should sum up to 1this restricti= on corresponding to the following piece of code: \ Flatten[MapThread[Equal,{M= ap[Apply[Plus,#]&,u],Table[1,{Length[u]}]}] How can I solve this?In general, what I am doing wrong so as to not repeat \ = === Subject: Mathematica Training in Amsterdam CANdiensten provides Mathematica courses which might be of interest to you or your colleagues. The courses are offered at our training facilities in Amsterdam. Register now for one, or more, of the following Mathematica courses: o Introduction to Mathematica o Programming with Mathematica Introduction to Mathematica by Professor Fred Simons ____________________________________________ March 10 and April 14 in Amsterdam - euro 95,- excluding VAT The course offers an overview of Mathematica's many rich features. The broad knowledge you acquire enables you to explore Mathematica after the course at your own pace. Registration and more information: http://www.can.nl/events/details.php?id=6 Programming with Mathematica by Professor Fred Simons ____________________________________ March 24 and May 19 in Amsterdam - euro 250,- excluding VAT All programming language functionality is available in Mathematica. Programs written in a standard programming language can be translated into a Mathematica program. However, this leads rarely to an efficient program. Often we can improve such a translation by using some more advanced Mathematica commands. Even better is to start from the very beginning and to use the structure of the dataset and the available functions in Mathematica for manipulation to arrive at the desired output. These principles will be demonstrated by many examples. Much attention will be paid to the speed of the programs. Registration and more information: http://www.can.nl/events/details.php?id If you have any questions, please feel free to contact me. Dick Verkerk Check out our complete event list at: http://www.can.nl/events/ _________________________ CANdiensten, Nieuwpoortkade 23-25, NL-1055 RX Amsterdam voice: +31 20 5608400 fax: +31 20 5608448 verkerk@can.nl _________________________ Your Partner in Finance, Mathematics and Statistics! === Subject: Re: Length of a held expression > > How can I get the length of a list in a Hold[] expression? It seems that in my attempt to produce a short example, I also simplified away the actual problem. So here it comes in slightly longer form. I have written a function that propagates uncertainties in the parameters of a function into the uncertainty of the result. It is used as follows: error[a*b, {a, b}, {aErr, bErr}] --> {a b, Sqrt[Abs[aErr b]^2 + Abs[a bErr]^2]} so it yields the formula again, together with its error. However, usually the parameter already have values assigned to them when I call the function. As was correctly pointed out, I can easily circumvent this problem by packing the call into a Block[]: a = 10; b = 20; aErr = 1; bErr = 2; Block[{a,b}, error[a*b, {a, b}, {aErr, bErr}]] However, I was wondering if it might not be possible to handle this case entirely in the error function, so that I can call a = 10; b = 20; aErr = 1; bErr = 2; error[a*b, {a, b}, {aErr, bErr}] and get the correct result. *So I am not really solving an actual problem here*, I'm just playing with Mathematica's programming model to see if it would allows me to do such a thing. I figured out that, in order to be really able to work with the unevaluated expression I cannot to wrap it in Hold[], but I have to \escape\ all the parameters that might otherwise be evaluated. So what I'm doing is this: SetAttributes[error, HoldAll]; error::varno = \There must be the same number of variables and errors\; error[expr_, vars_, errs_] := Module[{safeExpr, safeVars, res, escapeRule, restoreRule, varno}, varno = Length[vars]; If[varno != Length[errs], Message[error::varno]; Throw[$Failed]; ]; (* This replaces the given variables (which may have global definition= s) by local ones *) escapeRule = Table[ Extract[Hold[vars], {1, i}, HoldPattern] -> safeVars[i], {i, varno}]; (* This restores the original values of the variables *) restoreRule = Table[safeVars[i] -> vars[[i]], {i, varno}]; (* Escape variables, so that we can differentiate the expression *) safeExpr = ReleaseHold[Hold[expr] /. escapeRule]; (* Calculate result with error *) {expr, Sqrt[Plus @@ Table[ Abs[D[safeExpr, safeVars[i]] errs[[i]] /. restoreRule ]^2, {i, varno}]]} ] This indeed works nicely, except for one thing: in order to replace all the global variables in the expression by local ones, I have to iterate over the list of parameters, which in turn requires me to know it's length. However, if I'm calculating the length with Length[vars] as above, vars is evaluated first which may, in theory, change its length. (I cannot really come up with an example where this may actually happen, but as I said I'm not trying to solve a real problem anyway). Now that I've written this all up so nicely, I also realize that the solution with Length[Unevaluated[vars]] will also work for this case. I'm mailing this anyway now, since I've already spend so much time writing it. Maybe someone else can come up with a more elegant version to do the above, so this mail wasn't entirely pointless :-). Best, -Nikolaus -- =C2=BBTime flies like an arrow, fruit flies like a Banana.=C2=AB PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C === Subject: Re: Length of a held expression and Rules[] will not help ?? {a->10,b->20} intead of assigments ?? Jens > >> >> How can I get the length of a list in a Hold[] expression? > > It seems that in my attempt to produce a short example, I also > simplified away the actual problem. So here it comes in slightly > longer form. > > I have written a function that propagates uncertainties in the > parameters of a function into the uncertainty of the result. It is > used as follows: > > error[a*b, {a, b}, {aErr, bErr}] > > --> {a b, Sqrt[Abs[aErr b]^2 + Abs[a bErr]^2]} > > so it yields the formula again, together with its error. > > However, usually the parameter already have values assigned to them > when I call the function. As was correctly pointed out, I can easily > circumvent this problem by packing the call into a Block[]: > > a = 10; > b = 20; > aErr = 1; > bErr = 2; > Block[{a,b}, > error[a*b, {a, b}, {aErr, bErr}]] > > > However, I was wondering if it might not be possible to handle this > case entirely in the error function, so that I can call > > a = 10; > b = 20; > aErr = 1; > bErr = 2; > error[a*b, {a, b}, {aErr, bErr}] > > and get the correct result. *So I am not really solving an actual > problem here*, I'm just playing with Mathematica's programming model > to see if it would allows me to do such a thing. > > > I figured out that, in order to be really able to work with the > unevaluated expression I cannot to wrap it in Hold[], but I have to > \escape\ all the parameters that might otherwise be evaluated. So what > I'm doing is this: > > > SetAttributes[error, HoldAll]; > error::varno = \There must be the same number of variables and errors\; > error[expr_, vars_, errs_] := > Module[{safeExpr, safeVars, res, escapeRule, restoreRule, varno}, > varno = Length[vars]; > > If[varno != Length[errs], > Message[error::varno]; > Throw[$Failed]; > ]; > > (* This replaces the given variables (which may have global \ definition= > s) by local ones *) > escapeRule = Table[ > Extract[Hold[vars], {1, i}, HoldPattern] -> safeVars[i], > {i, varno}]; > > (* This restores the original values of the variables *) > restoreRule = Table[safeVars[i] -> vars[[i]], {i, varno}]; > > (* Escape variables, so that we can differentiate the expression *) > safeExpr = ReleaseHold[Hold[expr] /. escapeRule]; > > (* Calculate result with error *) > {expr, > Sqrt[Plus @@ Table[ > Abs[D[safeExpr, safeVars[i]] errs[[i]] /. restoreRule ]^2, > {i, varno}]]} > ] > > This indeed works nicely, except for one thing: in order to replace > all the global variables in the expression by local ones, I have to > iterate over the list of parameters, which in turn requires me to know > it's length. > > However, if I'm calculating the length with Length[vars] as above, > vars is evaluated first which may, in theory, change its length. (I > cannot really come up with an example where this may actually happen, > but as I said I'm not trying to solve a real problem anyway). > > > Now that I've written this all up so nicely, I also realize that the > solution with Length[Unevaluated[vars]] will also work for this case. > I'm mailing this anyway now, since I've already spend so much time > writing it. Maybe someone else can come up with a more elegant version > to do the above, so this mail wasn't entirely pointless :-). > > > > Best, > > -Nikolaus > > -- > =C2=BBTime flies like an arrow, fruit flies like a Banana.=C2=AB > > PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C > === Subject: Re: Length of a held expression > > How can I get the length of a list in a Hold[] expression? I.e. if > > b = Sequence[1,2]; > > then I want the length of {b,3} given as 2. But > > Length[{b,3}] > > gives me the length after splicing in b (which is 4), while > > Length[Hold[{b,3}]] > > gives me the length of the hold expression (which is 1). > > > Anyone able to help? > > > Best, > > -Nikolaus > > -- > =C2=BBTime flies like an arrow, fruit flies like a Banana.=C2=AB > > PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C > I think it would help to describe what you are trying to do at a slightly higher level, because Sequence does its thing even inside Hold - for example: Hold[Sequence[1, 2]] David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Length of a held expression > How can I get the length of a list in a Hold[] expression? I.e. if > > b = Sequence[1,2]; > > then I want the length of {b,3} given as 2. But > > Length[{b,3}] > > gives me the length after splicing in b (which is 4), while Which is 3 actually. > Length[Hold[{b,3}]] > > gives me the length of the hold expression (which is 1). You should use *Unevaluated* rather than *Hold*. In[1]:= b = Sequence[1, 2]; Length[Unevaluated[{b, 3}]] Out[2]= 2 In[3]:= Length[Unevaluated[1 + 2 + 3]] Out[3]= 3 In[4]:= Length[Hold[1 + 2 + 3]] Out[4]= 1 --Jean-Marc === Subject: Re: Length of a held expression I don't know whether this will suit your purpose (because I do not know what your purpose is) but by far the simplest way to get what you appear to want is: b = Sequence[1, 2]; Block[{b}, Length[{b, 3}]] 2 Andrzej Kozlowski > > How can I get the length of a list in a Hold[] expression? I.e. if > > b = Sequence[1,2]; > > then I want the length of {b,3} given as 2. But > > Length[{b,3}] > > gives me the length after splicing in b (which is 4), while > > Length[Hold[{b,3}]] > > gives me the length of the hold expression (which is 1). > > > Anyone able to help? > > > Best, > > -Nikolaus > > -- > =C2=BBTime flies like an arrow, fruit flies like a Banana.=C2=AB > > PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C > === Subject: Re: Length of a held expression Remember, Hold[{b,3}] is really just Hold[List[b,3]]. And what you're looking for is something like: Length[Hold[b,3]]. So replace head List with Hold, and head Hold with Length. Length @@ Hold @@@ Hold[{b,3}] === Subject: Re: Length of a held expression > Remember, Hold[{b,3}] is really just Hold[List[b,3]]. > > And what you're looking for is something like: Length[Hold[b,3]]. > > So replace head List with Hold, and head Hold with Length. > > Length @@ Hold @@@ Hold[{b,3}] Length[Unevaluated[a]] is more concise, I'm sure I'll be grateful for your construct at some later point. Best, -Nikolaus -- =C2=BBTime flies like an arrow, fruit flies like a Banana.=C2=AB PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C === Subject: Re: Length of a held expression Hi Nikolaus, obviously, your problem is to in-activate \Sequence\. This can be done by severals ways. The most natural seems using \Unevaluated\: Length[{Unevaluated[b], 3}] hope this helps, Daniel > > How can I get the length of a list in a Hold[] expression? I.e. if > > b = Sequence[1,2]; > > then I want the length of {b,3} given as 2. But > > Length[{b,3}] > > gives me the length after splicing in b (which is 4), while > > Length[Hold[{b,3}]] > > gives me the length of the hold expression (which is 1). > > > Anyone able to help? > > > Best, > > -Nikolaus > > -- > =C2=BBTime flies like an arrow, fruit flies like a Banana.=C2=AB > > PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C > === Subject: Re: Length of a held expression Hi Nikolaus, In[1] = Function[list, Length[Unevaluated[list]], HoldFirst] @@ Hold[{b, \ 3}] Out[1] = 2, Or In[2] = Block[{b}, Length @@ Hold[{b, 3}]] Out[2] = 2, or even In[3] = Block[{b}, Length[{b, 3}]] Out[3] = 2 Leonid > > How can I get the length of a list in a Hold[] expression? I.e. if > > b = Sequence[1,2]; > > then I want the length of {b,3} given as 2. But > > Length[{b,3}] > > gives me the length after splicing in b (which is 4), while > > Length[Hold[{b,3}]] > > gives me the length of the hold expression (which is 1). > > > Anyone able to help? > > > Best, > > -Nikolaus > > -- > =C2=BBTime flies like an arrow, fruit flies like a Banana.=C2=AB > > PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C > > === Subject: Re: Length of a held expression b = Sequence[1, 2]; Hold[{b, 3}] /. Hold[a_] :> Length[Unevaluated[a]] ?? Jens > > How can I get the length of a list in a Hold[] expression? I.e. if > > b = Sequence[1,2]; > > then I want the length of {b,3} given as 2. But > > Length[{b,3}] > > gives me the length after splicing in b (which is 4), while > > Length[Hold[{b,3}]] > > gives me the length of the hold expression (which is 1). > > > Anyone able to help? > > > Best, > > -Nikolaus > > -- > =C2=BBTime flies like an arrow, fruit flies like a Banana.=C2=AB > > PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C > === Subject: Re: Length of a held expression If for some reason you do not like to use Block, here is another pretty simple way: b = Sequence[1, 2]; Length @@ ReplacePart[Hold[{b, 3}], {i_, j_} :> xx] 2 Andrzej Kozlowski > I don't know whether this will suit your purpose (because I do not > know what your purpose is) but by far the simplest way to get what > you appear to want is: > > b = Sequence[1, 2]; > > Block[{b}, Length[{b, 3}]] > 2 > > > Andrzej Kozlowski > > > > >> >> How can I get the length of a list in a Hold[] expression? I.e. if >> >> b = Sequence[1,2]; >> >> then I want the length of {b,3} given as 2. But >> >> Length[{b,3}] >> >> gives me the length after splicing in b (which is 4), while >> >> Length[Hold[{b,3}]] >> >> gives me the length of the hold expression (which is 1). >> >> >> Anyone able to help? >> >> >> Best, >> >> -Nikolaus >> >> -- >> =C2=BBTime flies like an arrow, fruit flies like a Banana.=C2=AB >> >> PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C >> > === Subject: Re: Length of a held expression Here's one way In[17]:= SetAttributes[heldLength, HoldAll]; heldLength[e_] := Length[Part[Hold //@ Hold[e], 1, 1, 1]] In[19]:= b = Sequence[1, 2]; In[20]:= heldLength[{b, 2}] Out[20]= 2 Sam > > How can I get the length of a list in a Hold[] expression? I.e. if > > b = Sequence[1,2]; > > then I want the length of {b,3} given as 2. But > > Length[{b,3}] > > gives me the length after splicing in b (which is 4), while > > Length[Hold[{b,3}]] > > gives me the length of the hold expression (which is 1). > > > Anyone able to help? > > > Best, > > -Nikolaus > > -- > =C2=BBTime flies like an arrow, fruit flies like a Banana.=C2=AB > > PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C === Subject: Re: Length of a held expression b = Sequence[1, 2]; Length[Unevaluated@{b, 3}] 2 David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ How can I get the length of a list in a Hold[] expression? I.e. if b = Sequence[1,2]; then I want the length of {b,3} given as 2. But Length[{b,3}] gives me the length after splicing in b (which is 4), while Length[Hold[{b,3}]] gives me the length of the hold expression (which is 1). Anyone able to help? Best, -Nikolaus -- =C2=BBTime flies like an arrow, fruit flies like a Banana.=C2=AB PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C === Subject: pfa2pfb It seems that Mathematica provides fonts in the following forms: .pfa, .tfm, .afm. I must admit I don't know what all this means. dvips (a program used in conjunction with TeX and LaTex) apparently needs the fonts in the .pfb format. How does one construct a file of the correct type from the fonts provided by Mathematica. I'm using Mathematica 5.2. I could update using my university's site licence if that would help. Apparently there are programs with names like pfa2pfb, maybe one in perl. Does anyone know how I can get these? I work on Mac Os X 10.4.11. David Epstein === Subject: Re: pfa2pfb > It seems that Mathematica provides fonts in the following > forms: .pfa, .tfm, .afm. I must admit I don't know what all this > means. dvips (a program used in conjunction with TeX and LaTex) > apparently needs the fonts in the .pfb format. How does one construct > a file of the correct type from the fonts provided by Mathematica. > > I'm using Mathematica 5.2. I could update using my university's site > licence if that would help. Mathematica 6 & 7 include pfb versions of the Mathematica fonts. -Rob === Subject: Re: pfa2pfb that is nonsense, dvips work with binary *.pfb and ASCII PostScript fonts. Just find the font map file for dvips that comes with you Mathematica and add the texmf root that is part of the Mathematica distribution to the texmf roots that your TeX system searches. If you have MikTeX or teTeX fin the fontname/wolfram.map in the TeX installation root and delete it. This file is a false font map file, I have reported it several times to the developers but they had other things to do than to replace the file with the correct one that comes with Mathematica. Jens > It seems that Mathematica provides fonts in the following > forms: .pfa, .tfm, .afm. I must admit I don't know what all this > means. dvips (a program used in conjunction with TeX and LaTex) > apparently needs the fonts in the .pfb format. How does one construct > a file of the correct type from the fonts provided by Mathematica. > > I'm using Mathematica 5.2. I could update using my university's site > licence if that would help. > > Apparently there are programs with names like pfa2pfb, maybe one in > perl. Does anyone know how I can get these? > > I work on Mac Os X 10.4.11. > > David Epstein > === Subject: Re: pfa2pfb On Feb 17, 9:25 am, Jens-Peer Kuska > > that is nonsense, dvips work with binary *.pfb and ASCII > PostScript fonts. Just find the font map file for dvips > that comes with you Mathematica and add the texmf root > that is part of the Mathematica distribution to the > texmf roots that your TeX system searches. > > If you have MikTeX or teTeX fin the fontname/wolfram.map > in the TeX installation root and delete it. > This file is a false font map file, I have reported it several > times to the developers but they had other things to do than > to replace the file with the correct one that comes with > Mathematica. > > Jens > > > It seems that Mathematica provides fonts in the following > > forms: .pfa, .tfm, .afm. I must admit I don't know what all this > > means. dvips (a program used in conjunction with TeX and LaTex) > > apparently needs the fonts in the .pfb format. How does one construct > > a file of the correct type from the fonts provided by Mathematica. > > > I'm using Mathematica 5.2. I could update using my university's site > > licence if that would help. > > > Apparently there are programs with names like pfa2pfb, maybe one in > > perl. Does anyone know how I can get these? > > > I work on Mac Os X 10.4.11. > > > David Epstein I would have expected Wolfram to update the notebook.sty file they ship so that, at the very least, the example at the top uses LaTeX2e! Oh well :) -- m === Subject: Re: Division by zero, despite strong hint Just a missing comma between the arguments to Piecewise! Try g3[x_] := Piecewise[{{Sin[1/x], x != 0}, {0, x == 0}}] C.O. > > I'm trying to plot the Sin[1/x] curve with the curve being defined as > 0 at 0 like this: > > g3[x_] := Piecewise[{{Sin[1/x], x != 0} {0, x == 0}}] > > Invoking Plot produced a flat graph; puzzled I asked for g3[0] and > got: > > Power::infy Infinite expression 1/0 encountered >> > > { > {Indeterminate, False True}, > {0, \\!\\(\\* > TagBox[\True\, > \PiecewiseDefault\, > AutoDelete->False, > DeletionWarning->True]\\)} > } > > Hmmm... what's the trick here to stop Mathematica evaluating all the \ branches > of the piecewise fn? There's nothing in the documentation that I can > see to stop this in Piecewise... perhaps I need to use a different \ Mathematica > function? > > David. > > -- Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 Please avoid sending me Word or PowerPoint attachments See http://www.gnu.org/philosophy/no-word-attachments.html === Subject: Re: Division by zero, despite strong hint You left a comma out g3[x_] := Piecewise[{{Sin[1/x], x != 0}, {0, x == 0}}] Plot[g3[x], {x, 0, 1}, PlotStyle -> Red] However, the second condition is unnecessary since the default is zero g3[x_] := Piecewise[{{Sin[1/x], x != 0}}] Plot[g3[x], {x, 0, 1}, PlotStyle -> Red] Bob Hanlon I'm trying to plot the Sin[1/x] curve with the curve being defined as 0 at 0 like this: g3[x_] := Piecewise[{{Sin[1/x], x != 0} {0, x == 0}}] Invoking Plot produced a flat graph; puzzled I asked for g3[0] and got: Power::infy Infinite expression 1/0 encountered >> { {Indeterminate, False True}, {0, \\!\\(\\* TagBox[\True\, \PiecewiseDefault\, AutoDelete->False, DeletionWarning->True]\\)} } Hmmm... what's the trick here to stop Mathematica evaluating all the \ branches of the piecewise fn? There's nothing in the documentation that I can see to stop this in Piecewise... perhaps I need to use a different \ Mathematica function? David. === Subject: Re: Chain Matrix On Feb 14, 3:14 am, Jean-Marc Gulliet > > > > > I have a matrix in which all the elements are function of a scalar h, > > Say q[h]={{q1,q2},{q3,q4}} and what I need is to create a chain matri= x > > so I can obtain the dot product of several q[h]. For instance, if h= = > > {h1,h2,h3} > > I can create a large matrix with > > m=Map[q,h] > > Then I do > > Dot[m[[1]],m[[2],m[[3] ] > > > The problem is that there are cases where the Length[h] may reach a > > few hundreds and I do not want to write Dot[m[[1]], ..., m[[200]] ] > > So I have a somewhat trivial question: > > Is there any way I can do this automatically? I mean how can I creat= e > > a function to create an equivalent matrix from a chain of matrices? > > I tried some solutions with thread and fold, but I did not get > > anywhere, any thoughts are appreciated. > > If your matrices are stored within a list, as suggested by the syntax > m[[1]], etc., your could use either > > Dot[Sequence @@ m] > > or > > Fold[#1.#2 &, First[m], Rest[m]] > > for instance. > > In[1]:= m = Array[#, {2, 2}] & /@ {h1, h2, h3} > > Out[1]= {{{h1[1, 1], h1[1, 2]}, {h1[2, 1], h1[2, 2]}}, {{h2[1, 1], > h2[1, 2]}, {h2[2, 1], h2[2, 2]}}, {{h3[1, 1], h3[1, 2]}, {h3[2, 1]= , > h3[2, 2]}}} > > In[2]:= Dot[m[[1]], m[[2]], m[[3]]] > > Out[2]= {{(h1[1, 1] h2[1, 1] + h1[1, 2] h2[2, 1]) h3[1, > 1] + (h1[1, 1] h2[1, 2] + h1[1, 2] h2[2, 2]) h3[2, > 1], (h1[1, 1] h2[1, 1] + h1[1, 2] h2[2, 1]) h3[1, > 2] + (h1[1, 1] h2[1, 2] + h1[1, 2] h2[2, 2]) h3[2, > 2]}, {(h1[2, 1] h2[1, 1] + h1[2, 2] h2[2, 1]) h3[1, > 1] + (h1[2, 1] h2[1, 2] + h1[2, 2] h2[2, 2]) h3[2, > 1], (h1[2, 1] h2[1, 1] + h1[2, 2] h2[2, 1]) h3[1, > 2] + (h1[2, 1] h2[1, 2] + h1[2, 2] h2[2, 2]) h3[2, 2]}} > > In[3]:= Dot[Sequence @@ m] > > Out[3]= {{(h1[1, 1] h2[1, 1] + h1[1, 2] h2[2, 1]) h3[1, > 1] + (h1[1, 1] h2[1, 2] + h1[1, 2] h2[2, 2]) h3[2, > 1], (h1[1, 1] h2[1, 1] + h1[1, 2] h2[2, 1]) h3[1, > 2] + (h1[1, 1] h2[1, 2] + h1[1, 2] h2[2, 2]) h3[2, > 2]}, {(h1[2, 1] h2[1, 1] + h1[2, 2] h2[2, 1]) h3[1, > 1] + (h1[2, 1] h2[1, 2] + h1[2, 2] h2[2, 2]) h3[2, > 1], (h1[2, 1] h2[1, 1] + h1[2, 2] h2[2, 1]) h3[1, > 2] + (h1[2, 1] h2[1, 2] + h1[2, 2] h2[2, 2]) h3[2, 2]}} > > > Out[4]= True > > In[5]:= Fold[#1.#2 &, First[m], Rest[m]] > > Out[5]= {{(h1[1, 1] h2[1, 1] + h1[1, 2] h2[2, 1]) h3[1, > 1] + (h1[1, 1] h2[1, 2] + h1[1, 2] h2[2, 2]) h3[2, > 1], (h1[1, 1] h2[1, 1] + h1[1, 2] h2[2, 1]) h3[1, > 2] + (h1[1, 1] h2[1, 2] + h1[1, 2] h2[2, 2]) h3[2, > 2]}, {(h1[2, 1] h2[1, 1] + h1[2, 2] h2[2, 1]) h3[1, > 1] + (h1[2, 1] h2[1, 2] + h1[2, 2] h2[2, 2]) h3[2, > 1], (h1[2, 1] h2[1, 1] + h1[2, 2] h2[2, 1]) h3[1, > 2] + (h1[2, 1] h2[1, 2] + h1[2, 2] h2[2, 2]) h3[2, 2]}} > > > Out[6]= True > > --Jean-Marc Please refer to the book \Power Programming with Mathematica\ by David Wagner on page 169. Gary === Subject: Re: Typesetting bug Agreed: probably a bug. However, on my system [\7.0 for Linux x86 (32-bit) \ (November 11, 2008)\] the two answers are the same. C.O. > > I don't know whether this \feature\ is widely known or not, but it > surely gave me an hour of scratching my head, buried deep inside a > calculation: > > In[7]:= n = .5; > x = 1; > > ax = 1; > {(ax^n), x^n, ax^n - x^n} > > Out[10]= {1, 1, 0} > > In[11]:= max = 1; > {(max^n), x^n, max^n-x^n} > > Out[12]= {1, 1, -1} > > > This inconsistency happens only if exponents are typed in as real > superscripts with Ctrl+^. A FullForm reveals an underlying Times in > the last case, which ultimately is responsible for the wrong answer. > Furthermore, max^n does not work as intended if typed and evaluated in > one call, as follows: > max n x > because it is interpreted as a product of max^n and x. > > Istvan Zachar > > > -- Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 Please avoid sending me Word or PowerPoint attachments See http://www.gnu.org/philosophy/no-word-attachments.html === Subject: Re: Typesetting bug > > I don't know whether this \feature\ is widely known or not, but it > surely gave me an hour of scratching my head, buried deep inside a > calculation: > > In[7]:= n = .5; > x = 1; > > ax = 1; > {(ax^n), x^n, ax^n - x^n} > > Out[10]= {1, 1, 0} > > In[11]:= max = 1; > {(max^n), x^n, max^n-x^n} > > Out[12]= {1, 1, -1} > > > This inconsistency happens only if exponents are typed in as real > superscripts with Ctrl+^. A FullForm reveals an underlying Times in > the last case, which ultimately is responsible for the wrong answer. > Furthermore, max^n does not work as intended if typed and evaluated in > one call, as follows: > max n x > because it is interpreted as a product of max^n and x. > > Istvan Zachar Remove \max\ from the LimitsPositioningTokens list (Edit|Preferences| Advanced|Open Option Inspector|Formatting Options|Expression Formatting|Display Options); otherwise \max\ with a superscript is being treated as an operator. Maxim Rytin m.r@inbox.ru === Subject: Re: Typesetting bug Istvan, In the Presentations package I have formatting routines named 'comment' and 'command'. I used small 'c's deliberately to avoid any conflicts with Mathematica names. The package loads properly without any shadowing in a notebook, but one person loads the package in his init.m file and that \ gives a shadowing error - in Version 7. I have no idea why that happens and I'm not going to try to figure it out. Names that begin small case are supposed to be safe. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ Hi David, can you say more on this internal 'comment' bug? I couldn't find any info about it. Perhaps it would be worth to look for all the possible interfering words, that shouldn't be used as variable names, and then inform WRI. I certainly know about a \K\ that is not mentioned in the documentation, but still is a System' symbol (covered at /thread/f5d74f6c0ca98774/62974b25f30bb546?hl=en&lnk=gst&q=strange+%22= K%22#62974b25f30bb546). Istvan > I would say that it's a bug. Also you shouldn't have to put parentheses > around the first max^n. It's as if Mathematica is using 'max' internally \ = in > such a way to conflict with user expressions. They also use 'comment' > internally and let it leak out. > > David Park > djmp...@comcast.nethttp://home.comcast.net/~djmpark/ === Subject: Re: Problem with the 'if' command \Length[list]/2 == 0\ is the VERY wrong test. Clear[median, x] median[x_List] := Module[{n = Length@x, s = Sort@x}, If[OddQ@n, s[[(n + 1)/2]], Mean@s[[n/2 + {0, 1}]]] ] Array[median@Range@# &, 10] {1, 3/2, 2, 5/2, 3, 7/2, 4, 9/2, 5, 11/2} Array[Median@Range@# &, 10] {1, 3/2, 2, 5/2, 3, 7/2, 4, 9/2, 5, 11/2} Bobby > Hi everyone, > I'm a new Mathematica user so I may be missing something fairly obvious, \ > but I'm having trouble with the 'if' command. > I'm writing a function that is supposed to return the median of a list > (I know such a function already exists, but I need to create one myself). > > What I have is: > > newMedian[list_] := > If[Length[list]/2 == 0, > 1/2*(list[[(Length[list]/2) + 1]] + list[[(Length[list])/2]]) > , list[[(Length[list] + 1)/2]]] > > if the list has an off number of members (condition is false), it > evaluates as expected. If it's even, however, > > newMedian[{1, 2, 3, 4}] returns: > Part::pspec: Part specification 5/2 is neither an integer nor a list of > integers. > > BUT > > list={1,2,3,4}; > > 1/2*(list[[(Length[list]/2) + 1]] + list[[(Length[list])/2]]) > returns 5/2, as expected so that code is right. > > It seems likes its actually evaluating the false part of the code > (trying to find the 5/2'ith element in a list), even though the > condition is true. > > What's going on here? > > -- DrMajorBob@longhorns.com === Subject: Problem with the 'if' command Hi everyone, I'm a new Mathematica user so I may be missing something fairly obvious, but \ I'm having trouble with the 'if' command. I'm writing a function that is supposed to return the median of a list (I \ know such a function already exists, but I need to create one myself). What I have is: newMedian[list_] := If[Length[list]/2 == 0, 1/2*(list[[(Length[list]/2) + 1]] + list[[(Length[list])/2]]) , list[[(Length[list] + 1)/2]]] if the list has an off number of members (condition is false), it evaluates \ as expected. If it's even, however, newMedian[{1, 2, 3, 4}] returns: Part::pspec: Part specification 5/2 is neither an integer nor a list of \ integers. BUT list={1,2,3,4}; 1/2*(list[[(Length[list]/2) + 1]] + list[[(Length[list])/2]]) returns 5/2, as expected so that code is right. It seems likes its actually evaluating the false part of the code (trying to \ find the 5/2'ith element in a list), even though the condition is true. What's going on here? === Subject: Re: Problem with the 'if' command > Hi everyone, > I'm a new Mathematica user so I may be missing something fairly obvious, \ but I'm having trouble with the 'if' command. > I'm writing a function that is supposed to return the median of a list (I \ know such a function already exists, but I need to create one myself). > > What I have is: > > newMedian[list_] := > If[Length[list]/2 == 0, ^^^^^^^^^^^^^^^^^^^ Could it be you want something like: Mod[Length[list],2]==0 or even better EvenQ[Length[list]] here? Length[list]/2 == 0 will always return > 1/2*(list[[(Length[list]/2) + 1]] + list[[(Length[list])/2]]) > , list[[(Length[list] + 1)/2]]] > > if the list has an off number of members (condition is false), it \ evaluates as expected. If it's even, however, > > It seems likes its actually evaluating the false part of the code (trying \ to find the 5/2'ith element in a list), even though the condition is true. > hth, albert === Subject: Re: Problem with the 'if' command > Hi everyone, > I'm a new Mathematica user so I may be missing something fairly obvious, > but I'm having trouble with the 'if' command. > I'm writing a function that is supposed to return the median of a list (I \ > know such a function already exists, but I need to create one myself). > > What I have is: > > newMedian[list_] := > If[Length[list]/2 == 0, > 1/2*(list[[(Length[list]/2) + 1]] + list[[(Length[list])/2]]) > , list[[(Length[list] + 1)/2]]] > > if the list has an off number of members (condition is false), it > evaluates as expected. If it's even, however, > > newMedian[{1, 2, 3, 4}] returns: > Part::pspec: Part specification 5/2 is neither an integer nor a list of > integers. > > BUT > > list={1,2,3,4}; > > 1/2*(list[[(Length[list]/2) + 1]] + list[[(Length[list])/2]]) > returns 5/2, as expected so that code is right. > > It seems likes its actually evaluating the false part of the code (trying \ > to find the 5/2'ith element in a list), even though the condition is \ true. > > What's going on here? > > Your check for even is wrong. You were actually hitting the else part. Better to use EvenQ newMedian[list_] := Module[{len = Length[list]}, If[ EvenQ[len], (1/2)*(list[[len/2 + 1]] +list[[len/2]]), list[[(len + 1)/2]] ] ] newMedian[{1, 2, 3, 4}] 5/2 --Nasser === Subject: Re: Problem with the 'if' command your condition does not check for Even/Odd. Use EvenQ or OddQ for this purpose. hope this helps, Daniel > Hi everyone, > I'm a new Mathematica user so I may be missing something fairly obvious, \ but I'm having trouble with the 'if' command. > I'm writing a function that is supposed to return the median of a list (I \ know such a function already exists, but I need to create one myself). > > What I have is: > > newMedian[list_] := > If[Length[list]/2 == 0, > 1/2*(list[[(Length[list]/2) + 1]] + list[[(Length[list])/2]]) > , list[[(Length[list] + 1)/2]]] > > if the list has an off number of members (condition is false), it \ evaluates as expected. If it's even, however, > > newMedian[{1, 2, 3, 4}] returns: > Part::pspec: Part specification 5/2 is neither an integer nor a list of \ integers. > > BUT > > list={1,2,3,4}; > > 1/2*(list[[(Length[list]/2) + 1]] + list[[(Length[list])/2]]) > returns 5/2, as expected so that code is right. > > It seems likes its actually evaluating the false part of the code (trying \ to find the 5/2'ith element in a list), even though the condition is true. > > What's going on here? > > === Subject: Re: Problem with the 'if' command > if the list has an off number of members (condition is false) The only way that Length[list]/2 is 0 is that list is {}, or do you mean Mod[] ?? or would you like to use EvenQ[] ??? And even if this error is corrected, you code compute something strange, but not the median. Jens > Hi everyone, > I'm a new Mathematica user so I may be missing something fairly obvious, \ but I'm having trouble with the 'if' command. > I'm writing a function that is supposed to return the median of a list (I \ know such a function already exists, but I need to create one myself). > > What I have is: > > newMedian[list_] := > If[Length[list]/2 == 0, > 1/2*(list[[(Length[list]/2) + 1]] + list[[(Length[list])/2]]) > , list[[(Length[list] + 1)/2]]] > > if the list has an off number of members (condition is false), it \ evaluates as expected. If it's even, however, > > newMedian[{1, 2, 3, 4}] returns: > Part::pspec: Part specification 5/2 is neither an integer nor a list of \ integers. > > BUT > > list={1,2,3,4}; > > 1/2*(list[[(Length[list]/2) + 1]] + list[[(Length[list])/2]]) > returns 5/2, as expected so that code is right. > > It seems likes its actually evaluating the false part of the code (trying \ to find the 5/2'ith element in a list), even though the condition is true. > > What's going on here? > > === Subject: Re: Select All Lists Where Any Element is a Given Value X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}; Select[X, ! FreeQ[#, NA] &] {{8, NA, 20}, {-7, 9, NA}} Cases[X, _?(! FreeQ[#, NA] &)] {{8, NA, 20}, {-7, 9, NA}} DeleteCases[X, _?(FreeQ[#, NA] &)] {{8, NA, 20}, {-7, 9, NA}} X /. _List?(FreeQ[#, NA] &) :> Sequence[] {{8, NA, 20}, {-7, 9, NA}} Bob Hanlon Hello everyone, Suppose I have the list X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}, where NA is a string, although it need not be. How can I use Select to pull out all lists in X where NA appears in any element? In this example, I want to pull out the second and third list. Gregory === Subject: Re: Division by zero, despite strong hint >I'm trying to plot the Sin[1/x] curve with the curve being defined >as 0 at 0 like this: >g3[x_] := Piecewise[{{Sin[1/x], x != 0} {0, x == 0}}] >Invoking Plot produced a flat graph I have no problems with g3 as defined above. Is it possible you have previously defined x in the notebook where you tried this? Try doing this in a fresh session and see if you still have difficulties. === Subject: Re: Shortest Path Problem Hi. Here's another variation that is similar to the op's solution that uses the \Nearest\ function to find other points that are within Sqrt[2] away. (Rounded to 1.5 to make it a real number) {* All one entry *) Needs[\Combinatorica`\] n = 10; Rng = Range[n*n]; grid = RandomInteger[{1, 6}, {n*n}]; pairs = Tuples[Range@n, 2]; Near = Map[Rest[Nearest[pairs -> Automatic, #, {\\[Infinity], 1.5}]] &, pairs]; m = Table[ p = Complement[Rng, Near[[j]]]; p = List /@ p; ReplacePart[grid, p -> \\[Infinity]], {j, 1, n*n}]; Print[\Distance: \, CostOfPath[g, sp]]; MyGrid = Partition[grid, n]; MatrixPlot[MyGrid, Epilog -> {Thick, Line[{n - Mod[sp, n, 1] + 0.5, Quotient[sp - Mod[sp, n, 1], n] + 0.5}\\[Transpose]]}, ColorRules -> {1 -> Red, 2 -> Orange, 3 -> Green, 4 -> Blue, 5 -> Magenta, 6 -> Purple}] (* End of Entry *) (* I like the Grid Graph *) gg = GridGraph[n, n]; pth = Partition[sp, 2, 1]; gg = AddEdges[gg, pth]; ShowGraph[Highlight[gg, {pth}, HighlightedEdgeColors -> Red], VertexNumber -> True, VertexNumberColor -> Blue, EdgeStyle -> Thin, ImageSize -> 800] (* Some other ideas: I moved the axes around a little to match...*) ToLines[n_, b_] := {Mod[n, b, 1] - .5, Quotient[n, b, 1] + .5} MyLine = Line[Map[ToLines[#, n] &, sp]]; MatrixPlot[MyGrid, DataReversed -> {True, False}, Epilog -> { Circle[MyLine[[1, 1]], .3], Thick, MyLine, Disk[MyLine[[1, -1]], .1]}, ImageSize -> 800, ColorFunction -> ColorData[\LightTemperatureMap\]] = = = = HTH Dana DeLouis Using Ver 7 for Mac > > I am not familiar with Graph theory and hope that some Mathematica > users might help me. I am having a Shortest path problem that I hope > to solve using Mathematica. > > My input is a Grid defind as, > > MyGrid = Table[RandomInteger[{1, 5}], {i, 1, 10}, {j, 1, 10}] > > in this 10x10 grid i'd like the shortest path from point A, let's say > MyGrid[[10, 10]] to point B MyGrid[[1, 1]]. For every point inside > this square grid I have 8 possible directions or lines > (up,down,left,right and the 4 diagonals). The weight of each step is > given inside the MyGrid cell, i.e. let MyGrid[[2, 3]]=1 and MyGrid[[2, > 4]]=3 > So in going from coordinate (2,3) to (2,4) it takes 3 times as long as > if going from (2,4) to (2,3). So all directions are possible but they > are asymetrical in the sense that they have diferent weights if going > foward or backward. > > I tried reading Mathematica help but it is very poor with no examples. > All I know is that I have to use the Combinatorica package and the > ShortestPath[] command, but as a start I have no idea in how to create > a Graph needed as input to this command from MyGrid. > > === Subject: Re: Select All Lists Where Any Element is a Given Value On 2/16/09 at 4:40 PM, gregory.lypny@videotron.ca (Gregory Lypny) >Suppose I have the list >X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}, >where NA is a string, although it need not be. How can I use Select >to pull out all lists in X where NA appears in any element? In this >example, I want to pull out the second and third list. It is unclear to me what you mean by \pull out\. If you mean you want to keep all lists that have na in them somewhere, I would use Cases rather than Select as follows: In[1]:= x = {{1, 2, 3}, {8, na, 20}, {-7, 9, na}}; Cases[x, {___, na, ___}] Out[2]= {{8,na,20},{-7,9,na}} or if you mean to only keep those items without na in them: In[3]:= DeleteCases[x, {___, na, ___}] Out[3]= {{1,2,3}} === Subject: Factor by Grouping I am new to Mathmatica. I am trying to learn how to factor monomials and \ polynomials and at the same time learn Mathematica. How to I factoa equation \ such as 4+7xy-14y-2x I need to group to (x-2)(7y-2). Should be easy I think, but I can't actually figure out what the correct \ sequence would be. === Subject: Re: Factor by Grouping if you write \xy\ Mathematica can not know that you mean the product x y \ and not the variable xy. To factor there is (you guess) the function \Factor\ that does the job nicely. hope this helps, Daniel > I am new to Mathmatica. I am trying to learn how to factor monomials and \ polynomials and at the same time learn Mathematica. How to I factoa equation \ such as > > 4+7xy-14y-2x > > I need to group to (x-2)(7y-2). > > Should be easy I think, but I can't actually figure out what the correct \ sequence would be. > > > > > === Subject: Re: Factor by Grouping You need to leave a space between x and y or insert an '*'. Otherwise Mathematic treats xy as a new single variable. 4 + 7 x y - 14 y - 2 x; % // Factor (-2 + x) (-2 + 7 y) David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ I am new to Mathmatica. I am trying to learn how to factor monomials and polynomials and at the same time learn Mathematica. How to I factoa \ equation such as 4+7xy-14y-2x I need to group to (x-2)(7y-2). Should be easy I think, but I can't actually figure out what the correct sequence would be. === Subject: Re: Factor by Grouping Your polynomial won't factor, since xy is a third variable... not x*y. Correcting that, however: 4 + 7 x y - 14 y - 2 x // Factor (-2 + x) (-2 + 7 y) Bobby > I am new to Mathmatica. I am trying to learn how to factor monomials and \ > polynomials and at the same time learn Mathematica. How to I factoa > equation such as > > 4+7xy-14y-2x > > I need to group to (x-2)(7y-2). > > Should be easy I think, but I can't actually figure out what the correct \ > sequence would be. > > > > > -- DrMajorBob@longhorns.com === Subject: Re: Factor by Grouping Your polynomial has three inedeterminates: x, y and xy. Insert a space between x and y to get In[2]:= Factor[4 + 7 x y - 14 y - 2 x] Out[2]= (-2 + x) (-2 + 7 y) Adriano Pascoletti 2009/2/17 magnum > I am new to Mathmatica. I am trying to learn how to factor monomials and > polynomials and at the same time learn Mathematica. How to I factoa \ equation > such as > > 4+7xy-14y-2x > > I need to group to (x-2)(7y-2). > > Should be easy I think, but I can't actually figure out what the correct > sequence would be. > > > > > > === Subject: Re: Factor by Grouping Factor[4 + 7*x*y - 14 y - 2 x] Jens PS: x*y and x y is not xy > I am new to Mathmatica. I am trying to learn how to factor monomials and \ polynomials and at the same time learn Mathematica. How to I factoa equation \ such as > > 4+7xy-14y-2x > > I need to group to (x-2)(7y-2). > > Should be easy I think, but I can't actually figure out what the correct \ sequence would be. > > > > > === Subject: Re: Problem with the 'if' command You are testing the wrong condition, also you must ensure that the list is \ sorted and that the input is a list. newMedian[list_List] := Module[ {len = Length[list], sortedList = Sort[list]}, If[IntegerQ[len/2], (sortedList[[(len/2) + 1]] + sortedList[[len/2]])/2, sortedList[[(len + 1)/2]]]] newMedian2[list_List] := Module[ {len = Length[list], sortedList = Sort[list]}, If[Mod[len, 2] == 0, (sortedList[[(len/2) + 1]] + sortedList[[len/2]])/2, sortedList[[(len + 1)/2]]]] newMedian3[list_List] := Module[ {len = Length[list], sortedList = Sort[list]}, If[EvenQ[len], (sortedList[[(len/2) + 1]] + sortedList[[len/2]])/2, sortedList[[(len + 1)/2]]]] a = Table[RandomInteger[{0, 1000}, {RandomInteger[{10, 20}]}], {10000}]; And @@ (newMedian[#] == newMedian2[#] == newMedian3[#] == Median[#] & /@ a) True Bob Hanlon Hi everyone, I'm a new Mathematica user so I may be missing something fairly obvious, but \ I'm having trouble with the 'if' command. I'm writing a function that is supposed to return the median of a list (I \ know such a function already exists, but I need to create one myself). What I have is: newMedian[list_] := If[Length[list]/2 == 0, 1/2*(list[[(Length[list]/2) + 1]] + list[[(Length[list])/2]]) , list[[(Length[list] + 1)/2]]] if the list has an off number of members (condition is false), it evaluates \ as expected. If it's even, however, newMedian[{1, 2, 3, 4}] returns: Part::pspec: Part specification 5/2 is neither an integer nor a list of \ integers. BUT list={1,2,3,4}; 1/2*(list[[(Length[list]/2) + 1]] + list[[(Length[list])/2]]) returns 5/2, as expected so that code is right. It seems likes its actually evaluating the false part of the code (trying to \ find the 5/2'ith element in a list), even though the condition is true. What's going on here? === Subject: weird interpolation issues Hello I'm new to Mathematica and unfortunately am having some issues. I'm trying to construct a program to create an approximate symbolic function from a very large list of data points (6900 points, each with five associated variables). Mathematica is fritzing in two areas: first (this is probably trivial to fix), parallelization doesn't initialize; second, the lists of variables I'm extracting from my data table aren't being recognized as data points Mathematica can interpolate between. I've copied the plaintext of my source-code with comments explaining what each function is meant to do below. Edward Lieb This is the Function I use to import my table. This seems to work \ correctly: I get a list of numbers which matches my data q[]=Import[\C:\\wfout2_k1_b1_s1_in.dat\,\FieldSeperators\->\ \,\LineSeperators\->\/[NewLine]\ ,\RepeatedSeperators\->\True\] This is a function I use to switch rows and columns, so that I have five lists of values coresponsing to my variables instead of a list of ~60000 points each carrying five values w[q]:=Transpose[q]; This defines the last two variables as the real and complex values of the function I'm trying to create by interpolation wf[r_,c_]:=r+I*c; This is supposed to interpolate my imported values into a function DistributeDefinitions[w,wf,\\[Psi],q]; \\[Psi][x_,y_,z_,r_,c_]:=Interpolation[{x,y,z},Abs[wf[r,c]],{x,{w[[1]]}},{y,\ { w[[2]]}},{z,{w[[3]]}},{r,{w[[4]]}},{c,{w[[5]]}}]; This is supposed to make a graph of the function I made above with the function's values being shown by contour density ContourPlot3D[\\[Psi],{x,0,20},{y,0,20},{z,0,20}] No virus found in this outgoing message. Checked by AVG. === Subject: Help with project needed I'm about to attempt a project in which so many Mathematica related things are unclear to me that I will describe the project, rather than try to ask individual questions. Suppose that C is a function of alpha, but it also depends on a parameter epsilon, so I think of it as C[epsilon][alpha] -- but I'm OK with it if the implementation treats C as a function of two variables. This C is given. It's complicated, but one could easily obtain a series for it in epsilon. Now, I have the following operator that acts on functions of \r\, and \alpha\ (d is partial): L = C''(1-C')/(1+C^2) * d/dr + C'(1-C'') /(1-C')* d/dalpha For a given function f[r, alpha], I need to take successive orders in epsilon of the operator and apply it to f. I realize that for a given function f, I can form L[f] and the do Series[L[f], {epsilon, 0, 5}]. However, I'm very interested in seeing the operator decomposed into a series. I want to be able to say, here's the epsilon term of the operator, here's the epsilon squared term, and so forth. Can this be done. Can I decompose L into a series: L = L0 + L1 + L2 + .... and then be able to apply Ln to f? Aaron === Subject: Re: Help with project needed Hi Aaron, if I understand correctly, your operator L can be written: L= f1[eps,alpha] d/dr + f2[eps,alpha] d/dalpha now you can write f1 and f2 as series in epsilon. E.g. f[eps_,al_]:=Exp[eps+al]; Series[f[eps,al],{eps,0,5}] This gives an expansion of L in epsilon. hope this helps, Daniel > > I'm about to attempt a project in which so many Mathematica related > things are unclear to me that I will describe the project, rather than > try to ask individual questions. > > Suppose that C is a function of alpha, but it also depends on a > parameter epsilon, so I think of it as C[epsilon][alpha] -- but I'm OK > with it if the implementation treats C as a function of two variables. > This C is given. It's complicated, but one could easily obtain a > series for it in epsilon. > > Now, I have the following operator that acts on functions of \r\, and > \alpha\ (d is partial): > > L = C''(1-C')/(1+C^2) * d/dr + C'(1-C'') /(1-C')* d/dalpha > > For a given function f[r, alpha], I need to take successive orders in > epsilon of the operator and apply it to f. > > I realize that for a given function f, I can form L[f] and the do > Series[L[f], {epsilon, 0, 5}]. However, I'm very interested in seeing > the operator decomposed into a series. I want to be able to say, > here's the epsilon term of the operator, here's the epsilon squared > term, and so forth. Can this be done. Can I decompose L into a series: > > L = L0 + L1 + L2 + .... > > and then be able to apply Ln to f? > > > Aaron > === Subject: Re: Help with project needed A small bit of advice: C is a reserved name in Mathematica (as is K). So, to avoid conflicts and perhaps puzzling results, use a different name for your function... --David > Hi Aaron, > > if I understand correctly, your operator L can be written: > > L= f1[eps,alpha] d/dr + f2[eps,alpha] d/dalpha > > now you can write f1 and f2 as series in epsilon. E.g. > > f[eps_,al_]:=Exp[eps+al]; > > Series[f[eps,al],{eps,0,5}] > > This gives an expansion of L in epsilon. > > hope this helps, Daniel > > > > I'm about to attempt a project in which so many Mathematica related > > things are unclear to me that I will describe the project, rather than > > try to ask individual questions. > > > Suppose that C is a function of alpha, but it also depends on a > > parameter epsilon, so I think of it as C[epsilon][alpha] -- but I'm OK > > with it if the implementation treats C as a function of two variables. > > This C is given. It's complicated, but one could easily obtain a > > series for it in epsilon. > > > Now, I have the following operator that acts on functions of \r\, and > > \alpha\ (d is partial): > > > L = C''(1-C')/(1+C^2) * d/dr + C'(1-C'') /(1-C')* d/dalpha > > > For a given function f[r, alpha], I need to take successive orders in > > epsilon of the operator and apply it to f. > > > I realize that for a given function f, I can form L[f] and the do > > Series[L[f], {epsilon, 0, 5}]. However, I'm very interested in seeing > > the operator decomposed into a series. I want to be able to say, > > here's the epsilon term of the operator, here's the epsilon squared > > term, and so forth. Can this be done. Can I decompose L into a series: > > > L = L0 + L1 + L2 + .... > > > and then be able to apply Ln to f? > > > > Aaron === Subject: Using VerticalSlider controls for Manipulate In reference to the Manipulate function, does anyone know how to use row arranged variables with it, particular the VerticalSlider control if possible. As it it the only placement alignment is either top, bottom left or right but only in column formats, I want to use rows. I'm using Mathematica v6.0.2. Benjamin Tubb www.pdmusic.org === Subject: Re: Using VerticalSlider controls for Manipulate Benjamin, you might have a look at the earlier thread,\Custom label for a slider in Manipulate\. While I agree with David that Manipulate is not suitable for everything, for those still wanting to use it there is Control[] in Version 7 that allows you to place Manipulate control statements flexibly, e.g. in grids, columns etc. Yves > In reference to the Manipulate function, does anyone know how to use > row arranged variables with it, particular the VerticalSlider control > if possible. As it it the only placement alignment is either top, > bottom left or right but only in column formats, I want to use rows. > I'm using Mathematica v6.0.2. > > Benjamin Tubb > www.pdmusic.org > > === Subject: Re: Using VerticalSlider controls for Manipulate I found a \solution\ which might interest others, so here is an example. As my intent is to allow dynamic values with labels for the sliders, the \Button\ approach is the next best thing :>) Dynamic[a]; Dynamic[b]; a = 64; b = 64; Print[ Column[ { Row[ {VerticalSlider[Dynamic[a], {0, 127, 1}], , \ \, VerticalSlider[Dynamic[b], {0, 127, 1}]} ], Row[{Dynamic[Button[a]], \ \, Dynamic[Button[b]]}] } ] ] P.S. Ideally I'd like to use Mathematica perhaps with the Orchestra-95 text based music language (for programming \ease\) to allow both MIDI [SoundNote[] based] AND additive synthesis [Play[] based] playback of music playable polyphonically with the Sound[] function whether for algorithmic music or not!. But it would be very helpful if Mathematica could IMPORT MIDI files and \ just export them (unless Version 7 can now -- v6 doesn't). Benjamin Tubb www.pdmusic.org > > > > > > > Benjamin, > > > you might have a look at the earlier thread,\Custom label for a slider > > in Manipulate\. > > > While I agree with David that Manipulate is not suitable for \ everything= , > > for those still wanting to use it there is Control[] in Version 7 that > > allows you to place Manipulate control statements flexibly, e.g. in > > grids, columns etc. > > > Yves > > > > > In reference to the Manipulate function, does anyone know how to use > > > row arranged variables with it, particular the VerticalSlider control > > > if possible. As it it the only placement alignment is either top, > > > bottom left or right but only in column formats, I want to use rows. > > > I'm using Mathematica v6.0.2. > > > > Benjamin Tubb > > >www.pdmusic.org-Hide quoted text - > > > - Show quoted text - > > from Stephen Wolfram already (but it expires 5 Mar 09), having only > bought ver 3 previously, and can't afford to upgrade (to $2500!) > otherwise. As it is I'm trying to develop some music Demonstration > Projects on as fast a learning curve as I can, despite having two hard > drive crashes last year, and only (finally) recovering late last > month, but at least I have DSL service now , and a new (mfg. 12/08) > 300GB hard drive! And I'm still using a WinXP Pro PC.- Hide quoted text - > > - Show quoted text - === Subject: Re: Using VerticalSlider controls for Manipulate > Benjamin, > > you might have a look at the earlier thread,\Custom label for a slider > in Manipulate\. > > While I agree with David that Manipulate is not suitable for everything, > for those still wanting to use it there is Control[] in Version 7 that > allows you to place Manipulate control statements flexibly, e.g. in > grids, columns etc. > > Yves > > > > > > In reference to the Manipulate function, does anyone know how to use > > row arranged variables with it, particular the VerticalSlider control > > if possible. As it it the only placement alignment is either top, > > bottom left or right but only in column formats, I want to use rows. > > I'm using Mathematica v6.0.2. > > > Benjamin Tubb > >www.pdmusic.org- Hide quoted text - > > - Show quoted text - from Stephen Wolfram already (but it expires 5 Mar 09), having only bought ver 3 previously, and can't afford to upgrade (to $2500!) otherwise. As it is I'm trying to develop some music Demonstration Projects on as fast a learning curve as I can, despite having two hard drive crashes last year, and only (finally) recovering late last month, but at least I have DSL service now , and a new (mfg. 12/08) 300GB hard drive! And I'm still using a WinXP Pro PC. === Subject: Re: Using VerticalSlider controls for Manipulate Benjamin, Except for very simple things, I hardly use manipulate at all. In trying to do everything, Manipulate becomes very baroque and still doesn't do everything. In response to another question I presented a method for writing custom dynamic presentations that is rather easy and very general. http://forums.wolfram.com/mathgroup/archive/2009/Feb/msg00409.html Specifically, you can layout the information and controls in any manner you want using Rows and Columns, Panes or Panels, Grids or TabViews or any \ other constructs. The problem of handling the calculation of dependent dynamic variables is also quite easy. It is easy to make custom dynamics and I think once people try it they \ would use Manipulate much less often. It is just easier to understand what is happening. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ In reference to the Manipulate function, does anyone know how to use row arranged variables with it, particular the VerticalSlider control if possible. As it it the only placement alignment is either top, bottom left or right but only in column formats, I want to use rows. I'm using Mathematica v6.0.2. Benjamin Tubb www.pdmusic.org === Subject: Re: Using VerticalSlider controls for Manipulate Manipulate[ Graphics[{RGBColor[x, y, 0.5], Disk[{x, y}, 0.125]}, PlotRange -> {{0, 1}, {0, 1}}], {{y, 0.5}, 0, 1}, {{x, 0.5}, 0, 1, VerticalSlider}, ControlPlacement -> #] & /@ {{Bottom, Left}, {Left, Left}, {Right, Right}} ?? Jens > In reference to the Manipulate function, does anyone know how to use > row arranged variables with it, particular the VerticalSlider control > if possible. As it it the only placement alignment is either top, > bottom left or right but only in column formats, I want to use rows. > I'm using Mathematica v6.0.2. > > Benjamin Tubb > www.pdmusic.org > > === Subject: Re: Mathematica, ARPACK and implicit matrices No... Unless the eigenvalue is +/-1, the \Power method\ you describe will \ diverge (if the eigenvalue has absolute value > 1) or converge to 0 (if the absolute value < 1). If the eigenvalue is -1, your method (and mine below) will cycle between +/- the sought-for eigenvector. So... simple convergence won't occur unless the eigenvalue is 1. Here's a method similar to yours: m = RandomReal[{1}, {4, 4}] {{0.79066, 0.509111, 0.318938, 0.652391}, {0.828933, 0.790204, 0.714706, 0.132932}, {0.947251, 0.490976, 0.669439, 0.919992}, {0.03295, 0.0828506, 0.868529, 0.950574}} normalize = #/Norm@# &; Through[{Length, Last}@FixedPointList[normalize[m.#] &, {1, 0, 0, 0}]] {37, {0.445853, 0.527469, 0.602979, 0.399259}} eigen = Eigenvectors@m {{-0.445853, -0.527469, -0.602979, -0.399259}, {-0.164867, -0.78803, 0.013613, 0.592994}, {-0.487356 - 0.0761477 I, 0.667546 + 0. I, -0.244788 + 0.357903 I, 0.2391 - 0.256679 I}, {-0.487356 + 0.0761477 I, 0.667546 + 0. I, -0.244788 - 0.357903 I, 0.2391 + 0.256679 I}} We got convergence to (a scalar times) the first eigenvector, as you see. The same occurs even if we start with the second eigenvector (due to numerical inaccuracies): second = eigen[[2]] Through[{Length, Last}@FixedPointList[normalize[m.#] &, second]] {-0.164867, -0.78803, 0.013613, 0.592994} {72, {-0.445853, -0.527469, -0.602979, -0.399259}} The same would probably occur if we started with a non-zero vector perpendicular to the desired eigenvector, for the same numerical inaccuracy reasons. If the matrix is exact, however, starting with the second eigenvector we'd \ converge to the second eigenvector... IN THEORY. Actually, an exact matrix might lead to HUGE complexity in the intermediate results and precision errors in the test for convergence. Bobby > > > Hi Fernando, > > if the searched for eigenvalue is the largest in magnitude, your problem > > is easily solved by the \Power method\. > > Take an arbitrary vector, keep on multiplying it by your matrix until it > > cnoverges. This gives the eigenvector (provided you did not pick a start > > vector perpendicular to the eigenvector). > > > > hope this helps, Daniel > > > > >> I am trying to find the largest eigenvalue and associated eigenvector > >> of a very large matrix, mildly sparse but without a simple structure > >> -- that is, zero elements are arranged in a seemingly random way. > >> > >> Mathematica uses ARPACK routines for this task. However, it appears > >> that it wants to construct the matrix explicitly before starting. This > >> is strange when compared to how ARPACK works, and in fact it is the > >> one thing I was trying to avoid doing: Writing down the matrix takes > >> too much memory and time, even if it is sparse. > >> > >> ARPACK is designed to require not the matrix, but just a function that > >> gives the result of multiplying the matrix with an arbitrary vector. I > >> call this an implicit definition of the matrix, hence the subject of > >> the email. This would work very well with me since I have a compact > >> expression of the matrix in the form of a function that returns the > >> product with a vector, and I would not need to define the array > >> explicitly. > >> > >> I have been looking but I cannot find an option or a way to make > >> Mathematica give me the eigenvalues without writing the matrix > >> explicitly, any suggestions? > >> > >> Fernando Cucchietti > >> > > > -- DrMajorBob@longhorns.com === Subject: Re: Mathematica, ARPACK and implicit matrices Fernando, I had the same problem a while back (my matrices are 2^30 x 2^30). The only thing I found to do was to actually translate my code into a C program which calls ARPACK directly. This is actually not very hard, the documentation is good. You could then write a C procedure which calculates the largest eigenvalues (maybe dependent on some parameters), which you can call from Mathematica through MathLink. Effectively this will be exactly the Mathematica extension you seem to need. Roman. === Subject: Mathematica, ARPACK and implicit matrices I am trying to find the largest eigenvalue and associated eigenvector of a very large matrix, mildly sparse but without a simple structure -- that is, zero elements are arranged in a seemingly random way. Mathematica uses ARPACK routines for this task. However, it appears that it wants to construct the matrix explicitly before starting. This is strange when compared to how ARPACK works, and in fact it is the one thing I was trying to avoid doing: Writing down the matrix takes too much memory and time, even if it is sparse. ARPACK is designed to require not the matrix, but just a function that gives the result of multiplying the matrix with an arbitrary vector. I call this an implicit definition of the matrix, hence the subject of the email. This would work very well with me since I have a compact expression of the matrix in the form of a function that returns the product with a vector, and I would not need to define the array explicitly. I have been looking but I cannot find an option or a way to make Mathematica give me the eigenvalues without writing the matrix explicitly, any suggestions? Fernando Cucchietti === Subject: Re: Mathematica, ARPACK and implicit matrices That's a good idea, but still I/d like to know if I can get a few eigenvalues and vectors in Mathematica without writing the matrix down. This is not the first time I face this problem, but it is the first one I cannot avoid it. I was trying to find a more general solution, and using Mathematica's internal algorithms is the only way I know of keeping efficiency good. Fernando > > > Hi Fernando, > > if the searched for eigenvalue is the largest in magnitude, your > problem > > is easily solved by the \Power method\. > > Take an arbitrary vector, keep on multiplying it by your matrix > until it > > cnoverges. This gives the eigenvector (provided you did not pick a > start > > vector perpendicular to the eigenvector). > > > > hope this helps, Daniel > > > > >> I am trying to find the largest eigenvalue and associated eigenvector > >> of a very large matrix, mildly sparse but without a simple structure > >> -- that is, zero elements are arranged in a seemingly random way. > >> > >> Mathematica uses ARPACK routines for this task. However, it appears > >> that it wants to construct the matrix explicitly before starting. >> This > >> is strange when compared to how ARPACK works, and in fact it is the > >> one thing I was trying to avoid doing: Writing down the matrix takes > >> too much memory and time, even if it is sparse. > >> > >> ARPACK is designed to require not the matrix, but just a function >> that > >> gives the result of multiplying the matrix with an arbitrary >> vector. I > >> call this an implicit definition of the matrix, hence the subject of > >> the email. This would work very well with me since I have a compact > >> expression of the matrix in the form of a function that returns the > >> product with a vector, and I would not need to define the array > >> explicitly. > >> > >> I have been looking but I cannot find an option or a way to make > >> Mathematica give me the eigenvalues without writing the matrix > >> explicitly, any suggestions? > >> > >> Fernando Cucchietti > >> > > > === Subject: Re: Mathematica, ARPACK and implicit matrices Well, for some people one need to spell out all the details. If the vector gets bigger no harm is done, one simply has to normalize it. Daniel > No... Unless the eigenvalue is +/-1, the \Power method\ you describe > will diverge (if the eigenvalue has absolute value > 1) or converge to 0 > (if the absolute value < 1). If the eigenvalue is -1, your method (and > mine below) will cycle between +/- the sought-for eigenvector. So... > simple convergence won't occur unless the eigenvalue is 1. > > Here's a method similar to yours: > > m = RandomReal[{1}, {4, 4}] > > {{0.79066, 0.509111, 0.318938, 0.652391}, {0.828933, 0.790204, > 0.714706, 0.132932}, {0.947251, 0.490976, 0.669439, > 0.919992}, {0.03295, 0.0828506, 0.868529, 0.950574}} > > normalize = #/Norm@# &; > Through[{Length, Last}@FixedPointList[normalize[m.#] &, {1, 0, 0, 0}]] > > {37, {0.445853, 0.527469, 0.602979, 0.399259}} > > eigen = Eigenvectors@m > > {{-0.445853, -0.527469, -0.602979, -0.399259}, {-0.164867, -0.78803, > 0.013613, 0.592994}, {-0.487356 - 0.0761477 I, > 0.667546 + 0. I, -0.244788 + 0.357903 I, > 0.2391 - 0.256679 I}, {-0.487356 + 0.0761477 I, > 0.667546 + 0. I, -0.244788 - 0.357903 I, 0.2391 + 0.256679 I}} > > We got convergence to (a scalar times) the first eigenvector, as you see. > > The same occurs even if we start with the second eigenvector (due to > numerical inaccuracies): > > second = eigen[[2]] > Through[{Length, Last}@FixedPointList[normalize[m.#] &, second]] > > {-0.164867, -0.78803, 0.013613, 0.592994} > > {72, {-0.445853, -0.527469, -0.602979, -0.399259}} > > The same would probably occur if we started with a non-zero vector > perpendicular to the desired eigenvector, for the same numerical > inaccuracy reasons. > > If the matrix is exact, however, starting with the second eigenvector > we'd converge to the second eigenvector... IN THEORY. > > Actually, an exact matrix might lead to HUGE complexity in the > intermediate results and precision errors in the test for convergence. > > Bobby > > >> >> >> Hi Fernando, >> >> if the searched for eigenvalue is the largest in magnitude, your problem >> >> is easily solved by the \Power method\. >> >> Take an arbitrary vector, keep on multiplying it by your matrix until it >> >> cnoverges. This gives the eigenvector (provided you did not pick a start >> >> vector perpendicular to the eigenvector). >> >> >> >> hope this helps, Daniel >> >> >> >> >>> I am trying to find the largest eigenvalue and associated eigenvector >> >>> of a very large matrix, mildly sparse but without a simple structure >> >>> -- that is, zero elements are arranged in a seemingly random way. >> >>> >> >>> Mathematica uses ARPACK routines for this task. However, it appears >> >>> that it wants to construct the matrix explicitly before starting. This >> >>> is strange when compared to how ARPACK works, and in fact it is the >> >>> one thing I was trying to avoid doing: Writing down the matrix takes >> >>> too much memory and time, even if it is sparse. >> >>> >> >>> ARPACK is designed to require not the matrix, but just a function that >> >>> gives the result of multiplying the matrix with an arbitrary vector. I >> >>> call this an implicit definition of the matrix, hence the subject of >> >>> the email. This would work very well with me since I have a compact >> >>> expression of the matrix in the form of a function that returns the >> >>> product with a vector, and I would not need to define the array >> >>> explicitly. >> >>> >> >>> I have been looking but I cannot find an option or a way to make >> >>> Mathematica give me the eigenvalues without writing the matrix >> >>> explicitly, any suggestions? >> >>> >> >>> Fernando Cucchietti >> >>> >> >> >> > > > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail: Internet: === Subject: Re: Mathematica, ARPACK and implicit matrices Hi Fernando, if the searched for eigenvalue is the largest in magnitude, your problem is easily solved by the \Power method\. Take an arbitrary vector, keep on multiplying it by your matrix until it cnoverges. This gives the eigenvector (provided you did not pick a start vector perpendicular to the eigenvector). hope this helps, Daniel > I am trying to find the largest eigenvalue and associated eigenvector > of a very large matrix, mildly sparse but without a simple structure > -- that is, zero elements are arranged in a seemingly random way. > > Mathematica uses ARPACK routines for this task. However, it appears > that it wants to construct the matrix explicitly before starting. This > is strange when compared to how ARPACK works, and in fact it is the > one thing I was trying to avoid doing: Writing down the matrix takes > too much memory and time, even if it is sparse. > > ARPACK is designed to require not the matrix, but just a function that > gives the result of multiplying the matrix with an arbitrary vector. I > call this an implicit definition of the matrix, hence the subject of > the email. This would work very well with me since I have a compact > expression of the matrix in the form of a function that returns the > product with a vector, and I would not need to define the array > explicitly. > > I have been looking but I cannot find an option or a way to make > Mathematica give me the eigenvalues without writing the matrix > explicitly, any suggestions? > > Fernando Cucchietti > === Subject: Re: Why does Derivative fail in this case? >This example is self-explanatory: >f[x_, y_] := x y >g = f[##]*f[##] &; >h = Derivative[1, 0][g]; >g[x, y] >h[x, y] >I should expect that h[x, y] is 2 x y^2, but instead it is zero. How >come? Because g is not a function of either x or y. You have defined g to be a pure function. Doing g[x,y] does not change the definition of g. So, for the definition of h, Derivatitive[1, 0][g] is evaluated to 0& and this result is assigned to h. Consequently, any argument supplied to h will return 0. You can easily verify the value assigned to h by doing OwnValues[h] === Subject: Re: Extract Integrate values thank you for your help so far... but i get always the same mistakes after entering the solution of DH ... (<<1>> of piecewise is not a list of pairs) what is wrong? In[35]:= ex2piec[Integrate[model27SA, t]] During evaluation of In[35]:= Piecewise::pairs: The first argument \\ \\[Piecewise]<<1>> of Piecewise is not a list of pairs. Out[35]= Piecewise[Most[\\[Piecewise] { {0., t <= 40.}, {560.- 28. t + 0.35 t^2, 40. < t <= 50.}, {935.- 43. t + 0.5 t^2, 50. < t <= 55.}, {-123.75 - 4.5 t + 0.15 t^2, 55. < t <= 140.}, {-6983.75 + 93.5 t - 0.2 t^2, 140. < t <= 145.}, {-10137.5 + 137. t - 0.35 t^2, 145. < t <= 150.}, {-13512.5 + 182. t - 0.5 t^2, 150. < t <= 155.}, {-5103.75 + 73.5 t - 0.15 t^2, 155. < t <= 245.}, {3900., \\!\\(\\* TagBox[\True\, \PiecewiseDefault\, AutoDelete->False, DeletionWarning->True]\\)} }]] > > Manual typing of the above information to get it ploted: > > > } > > If[t <= 87.5, 0, > > If[t <= 137.5, 2679.6874999999995- 61.24999999999999 t + 0.35 t^2= , > > If[t <= 155, -10554.6875 + 131.25 t - 0.35 t^2, > > If[t <= 187.5, -6950.937500000001 + 84.75 t - > > 0.19999999999999996 t^2, > > If[t <= 205, > > 5353.750000000001 - 46.50000000000001 t + > > 0.15000000000000002 t^2, > > If[t <= 255, -7253.750000000001 + 76.50000000000001 t - > > 0.15000000000000002 t^2, 2500 > > ]]]]]]/31200 === Subject: Re: FourierTrigSeries[] and user-defined function > Am trying to have Mathematica to generated coefficient of Fourier > trigonometric series for simple step function, defined as follows: > f[x_ /; Mod[x, 2*Pi] <= Pi] := 1 > f[x_ /; Mod[x, 2*Pi] > Pi] := 2 > > I'm able to get the plot of the function: > Plot[f[x], {x, 0, 2*Pi}, PlotRange -> {0, 3}] > > However, when I try to generate Fourier coefficients: > FourierTrigSeries[f[x], x, 10] > Mathematica is just repeating the above expression as output (and > passing the expression to N[] or Evaluate[] doesn't help. > > Any suggestion here? Also, is it possible to not use Mod[] in the > function definition above, and to have Mathematica to \know\ that it > should \extend\ given function so that it behaves as periodic > function? > FourierTrigSeries will implicitly make the function periodic; all it does involves integrals over one period. You might define the function as a sum of box functions. Each of those can be done as unit steps with two borders (in Mathematica, that is UnitStep with two arguments). Mod will not work in this setting because FourierTrigSeries and related functions do not have any ability to handle an unevaluated \symbolic\ \ Mod. I assume your period is intended go from -2*Pi to 2*Pi, hence the nondefault FourierParameters setting below. Possibly instead you just mean to have a period from -Pi to Pi, in which case just shift your definition (which appears to be from 0 to 2*Pi and change the code below as needed. f[x_] := 2*UnitStep[x + 2*Pi, 2*Pi - x] - UnitStep[x + Pi, Pi - x] In[47]:= g[x_] = FourierTrigSeries[f[x], x, 9, FourierParameters -> {1, 1/2}] Out[47]= 3/2 - (2*Cos[x/2])/Pi + (2*Cos[(3*x)/2])/(3*Pi) - (2*Cos[(5*x)/2])/(5*Pi) + (2*Cos[(7*x)/2])/(7*Pi) - (2*Cos[(9*x)/2])/(9*Pi) Checking with Plot shows something plausible. Plot[g[x], {x, -20, 20}] Daniel Lichtblau Wolfram Research === Subject: FourierTrigSeries[] and user-defined function Am trying to have Mathematica to generated coefficient of Fourier trigonometric series for simple step function, defined as follows: f[x_ /; Mod[x, 2*Pi] <= Pi] := 1 f[x_ /; Mod[x, 2*Pi] > Pi] := 2 I'm able to get the plot of the function: Plot[f[x], {x, 0, 2*Pi}, PlotRange -> {0, 3}] However, when I try to generate Fourier coefficients: FourierTrigSeries[f[x], x, 10] Mathematica is just repeating the above expression as output (and passing the expression to N[] or Evaluate[] doesn't help. Any suggestion here? Also, is it possible to not use Mod[] in the function definition above, and to have Mathematica to \know\ that it should \extend\ given function so that it behaves as periodic function? === Subject: Re: Surface fitting error while using Fit in version 7 there is LinearModelFit that gives you the residues. In former versions there was something like \LinearRegression\ that gave residuals. hope this helps, Daniel > Hi > > I am using mathematica to fit data to a surface. My data is in a > matrix form: > Data1={{1.1, 7, 8.765}, {1.1, 7.5, 10.6481},.....,{1.9, 10.5, > 26.1048}} > > I want to get a form z=f(x,y) that fits this data, with x and y being > my first and second element of each vector. I expect the solution to > be a linear combination of x, y, xy and some constant term. > > So I tried > Fit[Data1, {1, x, y, xy}, {x, y}] > > and I get an error message: > Fit::fitm: Unable to solve for the fit parameters; the design matrix > is nonrectangular, non-numerical, or could not be inverted. > > I'm not sure what it meant by non-numerical (for example Data1[[1,1]] > gives 1.1 as expected). The data is rectangular and well defined (by > which I mean I never have cases like {x, , z} with y missing or > anything absurd like that). It cannot be inverted of course, but that > didn't seem to be a problem from the example 9 given here: > http://reference.wolfram.com/mathematica/tutorial/CurveFitting.html > > Any suggestions on what I need to do? > Srikanth > === Subject: Re: Surface fitting error while using Fit > I am using mathematica to fit data to a surface. My data is in a > matrix form: > Data1={{1.1, 7, 8.765}, {1.1, 7.5, 10.6481},.....,{1.9, 10.5, > 26.1048}} > > I want to get a form z=f(x,y) that fits this data, with x and y being > my first and second element of each vector. I expect the solution to > be a linear combination of x, y, xy and some constant term. > > So I tried > Fit[Data1, {1, x, y, xy}, {x, y}] > > and I get an error message: > Fit::fitm: Unable to solve for the fit parameters; the design matrix > is nonrectangular, non-numerical, or could not be inverted. > > I'm not sure what it meant by non-numerical (for example Data1[[1,1]] > gives 1.1 as expected). The data is rectangular and well defined (by > which I mean I never have cases like {x, , z} with y missing or > anything absurd like that). It cannot be inverted of course, but that > didn't seem to be a problem from the example 9 given here: > http://reference.wolfram.com/mathematica/tutorial/CurveFitting.html > > Any suggestions on what I need to do? It is very likely that some of the matrix entries are represented as *String* rather than as numbers, which means that, by visual inspection, you see them as numbers --- since, by default, Mathematica does not display the double-quote characters that surround a string --- but they are represented internally as string of characters, indeed. Among many other ways offered by Mathematica, you can check whether your matrix contains only numeric expressions with MatrixQ[data1, NumericQ] and you can convert strings into numbers with data1 /. s_String :> ToExpression[s] For instance, In[1]:= data1 = {{1.1, 7, 8.765}, {1.1, \7.5\, 10.6481}, {1.9, 10.5, 26.1048}} Dimensions[data1] MatrixQ[data1, NumericQ] Fit[data1, {1, x, y, x*y}, {x, y}] data1 = data1 /. s_String :> ToExpression[s] MatrixQ[data1, NumericQ] Fit[data1, {1, x, y, x*y}, {x, y}] Out[1]= {{1.1, 7, 8.765}, {1.1, \7.5\, 10.6481}, {1.9, 10.5, 26.1048}} Out[2]= {3, 3} Out[3]= False During evaluation of In[1]:= Fit::fitm: Unable to solve for the fit \\ parameters; the design matrix is nonrectangular, non-numerical, or \\ could not be inverted. >> Out[4]= Fit[{{1.1, 7, 8.765}, {1.1, \7.5\, 10.6481}, {1.9, 10.5, 26.1048}}, {1, x, y, x y}, {x, y}] Out[5]= {{1.1, 7, 8.765}, {1.1, 7.5, 10.6481}, {1.9, 10.5, 26.1048}} Out[6]= True Out[7]= -10.6512 - 6.31562 x + 2.56005 y + 1.0965 x y --Jean-Marc === Subject: Re: Surface fitting error while using Fit non-brute force method to check the absolute error in the fit curve (by which I mean that given the approximation, I could always generate the data, compare it with my true data and find the error. But I was wondering if there is something that Fit returns directly). Srikanth === Subject: Re: Surface fitting error while using Fit Hi Srikanth, you should give an full example. Otherwise I can not tell what you are doing wrong. Here is a working example: d = Flatten[Table[{x, y, x + 2 y + 3 x y + Random[]}, {x, 1.1, 1.9, 0.1}, {y,7.5, 10.5, 0.5}], 1]; Fit[d, {1, x, y, x y}, {x, y}] hope this helps, Daniel > Hi > > I am using mathematica to fit data to a surface. My data is in a > matrix form: > Data1={{1.1, 7, 8.765}, {1.1, 7.5, 10.6481},.....,{1.9, 10.5, > 26.1048}} > > I want to get a form z=f(x,y) that fits this data, with x and y being > my first and second element of each vector. I expect the solution to > be a linear combination of x, y, xy and some constant term. > > So I tried > Fit[Data1, {1, x, y, xy}, {x, y}] > > and I get an error message: > Fit::fitm: Unable to solve for the fit parameters; the design matrix > is nonrectangular, non-numerical, or could not be inverted. > > I'm not sure what it meant by non-numerical (for example Data1[[1,1]] > gives 1.1 as expected). The data is rectangular and well defined (by > which I mean I never have cases like {x, , z} with y missing or > anything absurd like that). It cannot be inverted of course, but that > didn't seem to be a problem from the example 9 given here: > http://reference.wolfram.com/mathematica/tutorial/CurveFitting.html > > Any suggestions on what I need to do? > Srikanth > === Subject: Re: Surface fitting error while using Fit xy is not x*y and not x y and data = Flatten[Table[{x, y, 1 + x*y}, {x, 0, 1, 0.1}, {y, 0, 1, 0.1}], 1]; Fit[data, {1, x, y, x*y}, {x, y}] gives 1. + 5.11805*10^-16 x + 2.04722*10^-16 y + 1. x y Jens > Hi > > I am using mathematica to fit data to a surface. My data is in a > matrix form: > Data1={{1.1, 7, 8.765}, {1.1, 7.5, 10.6481},.....,{1.9, 10.5, > 26.1048}} > > I want to get a form z=f(x,y) that fits this data, with x and y being > my first and second element of each vector. I expect the solution to > be a linear combination of x, y, xy and some constant term. > > So I tried > Fit[Data1, {1, x, y, xy}, {x, y}] > > and I get an error message: > Fit::fitm: Unable to solve for the fit parameters; the design matrix > is nonrectangular, non-numerical, or could not be inverted. > > I'm not sure what it meant by non-numerical (for example Data1[[1,1]] > gives 1.1 as expected). The data is rectangular and well defined (by > which I mean I never have cases like {x, , z} with y missing or > anything absurd like that). It cannot be inverted of course, but that > didn't seem to be a problem from the example 9 given here: > http://reference.wolfram.com/mathematica/tutorial/CurveFitting.html > > Any suggestions on what I need to do? > Srikanth > === Subject: Re: Surface fitting error while using Fit xy is a separate symbol, not the product of the symbols x and y. Try x*y Bob Hanlon Hi I am using mathematica to fit data to a surface. My data is in a matrix form: Data1={{1.1, 7, 8.765}, {1.1, 7.5, 10.6481},.....,{1.9, 10.5, 26.1048}} I want to get a form z=f(x,y) that fits this data, with x and y being my first and second element of each vector. I expect the solution to be a linear combination of x, y, xy and some constant term. So I tried Fit[Data1, {1, x, y, xy}, {x, y}] and I get an error message: Fit::fitm: Unable to solve for the fit parameters; the design matrix is nonrectangular, non-numerical, or could not be inverted. I'm not sure what it meant by non-numerical (for example Data1[[1,1]] gives 1.1 as expected). The data is rectangular and well defined (by which I mean I never have cases like {x, , z} with y missing or anything absurd like that). It cannot be inverted of course, but that didn't seem to be a problem from the example 9 given here: http://reference.wolfram.com/mathematica/tutorial/CurveFitting.html Any suggestions on what I need to do? Srikanth === Subject: Re: Benchmark performance Under AIX The problem, I think, has to do with the math library routines of AIX for the trig functions. You might look into getting newer math libraries on your AIX system, but not sure if Mathematica would use them as it depends on whether it is dynamically or statically linked. Does anyone know? The same problem exists on the Mac OS X version of Mathematica. On version 6.0.3 of Mathematica the test #5 results for a 3 GHz Intel CPU on Mac OS X were 10.3 seconds and for the same exact CPU on Windows the result was 4.03 seconds, which is about 2.5 times better for that one test on Windows. The overall result for Mac was 37.4 seconds (2.3 score) vs 30.4 seconds (2.84 score) for Windows. At the time I noticed this, I looked at each of the functions in the #5 test and I recall that the trig stuff was using most of the time. And I believe the difference was due to the different older math libraries Wolfram used on Mac OS X due to the newest Intel libraries not running on older versions of Mac OS X. Looking at the performance of an AIX system on the V6 benchmark it had a 60.13 sec for #5 and a 163.75 seconds overall (on an AIX 5.3 Power 4 1GHz cpu), so the performance on this one test was about 37% of all the time took, so bad results on this one test really skews the overall results. You might talk to AIX system provider and see if they know of ways to speed up math routines on it. The Mathematica v7 results for an Intel 3.0 GHz 5160 cpu were - for #5 test Mac OS X took 7.64 seconds and Windows took 4.03 seconds and for overall Mac OS X 34.84 seconds (2.47 score) and Windows 30.39 seconds (2.84 score), so the Mac OS X score has improved from V6 to V7, but I have not examined the benchmarks in detail to know if the two are exactly the same between the two versions of Mathematica, but I did look at the test #5 results for the V6 and V7 benchmarks are they are very very similar (V7 uses RandomArray[Real,...] and Exp[m1] and V7 uses RandomReal[] and e^m1) for 2 million exponentiations, sins and arctans. Since V7 of Mathematica requires Mac OS X 10.4 or newer, I am guessing they were able to use newer Intel math libraries (and hence faster than previous versions). These newer Intel math libraries gave about 30% improvement in just these trig functions (but only about 7% overall) on Mac OS X. I rather doubt that Wolfram did much improvement in the way they do Sin and ArcTan and Exp but it is possible. I think V6 of Mathematica required Mac OS X 10.2 or newer (not sure). -Bob > > I've been doing some benchmark testing of a new IBM Server running AIX > that we use for Mathematica. In particular I am using the > MathematicaMark6 tests that come with Mathematica v6.03. I've gotten > a puzzling result and I was wondering if anyone else on MathGroup has > seem a similar issue. > > Briefly, we have Grid-Mathematica installed on an 6-CPU p500 series > IBM server (the machine uses PowerPC Power6 CPUs at 4.2 Ghz each) with > 32Gb of Ram, running ver 5.3 of 64bit AIX (IBM's Unix). I've been > comparing the performance of this machine versus my standard 2Ghz > Laptop running Windows 2000. (Note: I am not making use of any grid > capabilities on the server) > > Given the configurations of each machine, I would expect the server to > be as much as 2x as fast as my laptop, given the difference in CPU > speeds if nothing else. But this is not the case. The server results in > a MathematicaMark6 score of 1.37 versus 1.67 for my laptop. I've traced > the difference to Test #5 (Elementary Functions). The benchmark code for > this test is: > > Test 5:Elementary Functions > > Module[{m1,m2},Timing[SeedRandom[1];m1=RandomArray[Real,{},{2000000}]; > m2=RandomArray[Real,{},{2000000}]; > Do[E^m1;Sin[m1];ArcTan[m1,m2],{30}]]] > > > This code takes 6.06 seconds on my laptop and 26.8 seconds on the > server! > > I'm wondering if there is a known issue on AIX (or UNIX systems more > generally) that might account for this? > > > Mark === Subject: Re: Benchmark performance Under AIX Hi Jens, Interesting point. I actually copied this verbatim from the MathematicaMark6 output page. I will look into this more. Mark -----Original Message----- === Subject: Re: Benchmark performance Under AIX m2 = RandomArray[Real, {}, {20}] gives RandomArray[Real, {}, {20}] Do you mean RandomReal[{}, {20}] ?? Jens > > I've been doing some benchmark testing of a new IBM Server running AIX > that we use for Mathematica. In particular I am using the > MathematicaMark6 tests that come with Mathematica v6.03. I've gotten a > puzzling result and I was wondering if anyone else on MathGroup has > seem a similar issue. > > Briefly, we have Grid-Mathematica installed on an 6-CPU p500 series > IBM server (the machine uses PowerPC Power6 CPUs at 4.2 Ghz each) with > 32Gb of Ram, running ver 5.3 of 64bit AIX (IBM's Unix). I've been > comparing the performance of this machine versus my standard 2Ghz > Laptop running Windows 2000. (Note: I am not making use of any grid > capabilities on the server) > > Given the configurations of each machine, I would expect the server to > be as much as 2x as fast as my laptop, given the difference in CPU > speeds if nothing else. But this is not the case. The server results > in a MathematicaMark6 score of 1.37 versus 1.67 for my laptop. I've > traced the difference to Test #5 (Elementary Functions). The benchmark > code for this test is: > > Test 5:Elementary Functions > > = Module[{m1,m2},Timing[SeedRandom[1];m1=RandomArray[Real,{},{2000000}]; > m2=RandomArray[Real,{},{2000000}]; > Do[E^m1;Sin[m1];ArcTan[m1,m2],{30}]]] > > > This code takes 6.06 seconds on my laptop and 26.8 seconds on the > server! > > I'm wondering if there is a known issue on AIX (or UNIX systems more > generally) that might account for this? > > > Mark === Subject: PlotStyle will not distribute over Table I create several functions using Table and want to plot them on the same plot with different styles. However, it seems that the last style in the list of PlotStyle options is used for all the lines. E.g. Plot[Table[Sin[a x], {a, 1, 2}], {x, 0, Pi}, PlotStyle -> {Hue[0.7], Hue[1]}] will have both lines with red color, while Plot[{Sin[ x], Sin[2 x]} , {x, 0, Pi}, PlotStyle -> {Hue[0.7], Hue[1]}] works correctly. Any idea how to make first version work? (I have Mathematica 6.0) Kresimir === Subject: Re: PlotStyle will not distribute over Table oversimplified my problem: > Plot[Table[Sin[a x], {a, 1, 2}], {x, 0, Pi}, > PlotStyle -> {Hue[0.7], Hue[1]}] > > will have both lines with red color, while Namely, \Sin[a x]\ above is actually a MathLink-ed function evaluated in Fortran for some value of x, and what's worse, this Fortran in the middle of evaluation calls back Mathematica and asks about the value of global variable parameter \par\ which should be set equal to \a\ before evaluation. I think this behaviour is equivalent to Mathematica function, e.g., fun[x_?NumericQ] := Sin[par x] Thus, what I originally had as an argument of Table[] instead of \Sin[a x]\ above was (par = a; fun[x]) Then I cannot put Evaluate[] around Table because only the last value for par=a would be used in evaluation of all functions. In the meantime I have solved the problem by using auxiliary function, which serves only to break this whole evaluation in two steps: aux[f_, a_, x_?NumericQ] := (par = a; f[x]) Plot[Evaluate[Table[aux[fun, a, x], {a, 2}]], {x, 0, Pi}, PlotStyle -> {Hue[0.7], Hue[1]}] I don't know if this is the most elegant solution, but it works for me. Kresimir === Subject: Re: PlotStyle will not distribute over Table Try Plot[Evaluate[Table[Sin[a x], {a, 1, 2}]], {x, 0, Pi}, PlotStyle -> {Hue[0.7], Hue[1]}] Ingolf Dahl Sweden -----Original Message----- === Subject: PlotStyle will not distribute over Table I create several functions using Table and want to plot them on the same plot with different styles. However, it seems that the last style in the list of PlotStyle options is used for all the lines. E.g. Plot[Table[Sin[a x], {a, 1, 2}], {x, 0, Pi}, PlotStyle -> {Hue[0.7], Hue[1]}] will have both lines with red color, while Plot[{Sin[ x], Sin[2 x]} , {x, 0, Pi}, PlotStyle -> {Hue[0.7], Hue[1]}] works correctly. Any idea how to make first version work? (I have Mathematica 6.0) Kresimir === Subject: Re: PlotStyle will not distribute over Table Hi Kresimir, Plot has the attribute HoldAll. Therefore Table is not evaluated before being fed to Plot. This makes Plot think that there is only one curve. You may improve this by wrapping Table[..] into Evaluate to enforce evaluation before plotting. There is another reason you should do this, otherwise Table is evaluated for every point of your plot. hope this helps, Daniel > I create several functions using Table and want to plot them > on the same plot with different styles. However, it seems that > the last style in the list of PlotStyle options is used for all > the lines. E.g. > > Plot[Table[Sin[a x], {a, 1, 2}], {x, 0, Pi}, > PlotStyle -> {Hue[0.7], Hue[1]}] > > will have both lines with red color, while > > Plot[{Sin[ x], Sin[2 x]} , {x, 0, Pi}, > PlotStyle -> {Hue[0.7], Hue[1]}] > > works correctly. Any idea how to make first version work? > (I have Mathematica 6.0) > > Kresimir > > === Subject: Re: PlotStyle will not distribute over Table and because Plot[] has the attribute HoldAll, it can't find out that Plot[Table[Sin[a x], {a, 1, 2}], {x, 0, Pi}, PlotStyle -> {Hue[0.7], Hue[1]}] has a List[] as result and so it handle it as a single function and not as a list of functions. The single function is colored in one color, a list of functions in different colors. So you must enable Mathematica to detect that you have a list of functions and write Plot[ Evaluate[ Table[Sin[a x], {a, 1, 2}] ], {x, 0, Pi}, PlotStyle -> {Hue[0.7], Hue[1]}] Jens > I create several functions using Table and want to plot them > on the same plot with different styles. However, it seems that > the last style in the list of PlotStyle options is used for all > the lines. E.g. > > Plot[Table[Sin[a x], {a, 1, 2}], {x, 0, Pi}, > PlotStyle -> {Hue[0.7], Hue[1]}] > > will have both lines with red color, while > > Plot[{Sin[ x], Sin[2 x]} , {x, 0, Pi}, > PlotStyle -> {Hue[0.7], Hue[1]}] > > works correctly. Any idea how to make first version work? > (I have Mathematica 6.0) > > Kresimir > > === Subject: Re: weird interpolation issues >I'm new to Mathematica and unfortunately am having some issues. I'm >trying to construct a program to create an approximate symbolic >function from a very large list of data points (6900 points, each >with five associated variables). Mathematica is fritzing in two >areas: first (this is probably trivial to fix), parallelization >doesn't initialize; second, the lists of variables I'm extracting >from my data table aren't being recognized as data points >Mathematica can interpolate between. I've copied the plaintext of my >source-code with comments explaining what each function is meant to >do below. >This is the Function I use to import my table. This seems to work >correctly: I get a list of numbers which matches my data >q[]=Import[\C:\\wfout2_k1_b1_s1_in.dat\,\FieldSeperators\->\ >\,\LineSeperators\->\/[NewLine]\ ,\RepeatedSeperators\->\True\] I very strongly suspect this is not doing what you think. I can think of no reason to create a function with no arguments and then define it to have a value equal to the data being read in. That is what you are doing with q[]. I am almost certain you would be better off using a simple variable, q, i.e. q = Import[\C ... >This is a function I use to switch rows and columns, so that I have >five lists of values coresponsing to my variables instead of a list >of ~60000 points each carrying five values >w[q]:=Transpose[q]; You want to use w = Transpose[q] here. Note you could do this in one step by doing w = Transpose@Import[\C: ... dispensing with any need for q. >This defines the last two variables as the real and complex values >of the function I'm trying to create by interpolation >wf[r_,c_]:=r+I*c; When using SetDelayed (:=) there is no need to terminate the definition with a ;. The whole point of SetDelayed is to delay evaluation. Consequently, there is no output returned when you don't terminate the definition with a ;. Of course, using a ; to terminate the definition causes no harm. It doesn't do anything in this case. >This is supposed to interpolate my imported values into a function >DistributeDefinitions[w,wf,\\[Psi],q]; I would define all of the functions before making a call to DistributeDefinitions. The order you've done things may work. It isn't clear to me whether it will or not from the documentation. >\\[Psi][x_,y_,z_,r_,c_]:=Interpolation[{x,y,z},Abs[wf[r,c]],{x,{w[[1] >]}},{y,{ w[[2]]}},{z,{w[[3]]}},{r,{w[[4]]}},{c,{w[[5]]}}]; It isn't clear to me what this function is supposed to do. I very much suspect you do not have it defined in a sensible manner. Looking below, I see you are using x,y and z to be scalars given values to be supplied by ContourPlot. That means the first argument to Interpolation is a list of 3 elements, the next is whatever is returned by wf, followed by arguments of the form {number, {{number, number .... }}}. This doesn't look like anything Interpolation is designed to accept. Look at the documentation for Interpolation. >This is supposed to make a graph of the function I made >above with the function's values being shown by contour density >ContourPlot3D[\\[Psi],{x,0,20},{y,0,20},{z,0,20}] This will be returned unevaluated by Mathematica. At the very least this needs to be re-written as: ContourPlot3D[\\[Psi][x,y,z,r,c],{x,0,20},{y,0,20},{z,0,20}] That is you need to call \\[Psi] with the arguments you defined it to require. Note, the way I've rewritten things it still won't work since neither r nor c are defined. === Subject: Re: Select All Lists Where Any Element is a Given Value Hello Gregory, You'll probably receive many good solutions. Does this do what you want? In[14]:= mylst={{1,2,3},{8,NA,20},{-7,9,NA},{NA,3,5}}; In[15]:= Cases[mylst,{___,PatternSequence[NA],___}] Out[15]= {{8,NA,20},{-7,9,NA},{NA,3,5}} Richard Hofler ________________________________ === Subject: Select All Lists Where Any Element is a Given Value Hello everyone, Suppose I have the list X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}, where NA is a string, although it need not be. How can I use Select to pull out all lists in X where NA appears in any element? In this example, I want to pull out the second and third list. Gregory === Subject: Re: Select All Lists Where Any Element is a Given Value In[1]:= X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}; In[2]:= Select[X, MemberQ[#1, NA] & ] Out[2]= {{8, NA, 20}, {-7, 9, NA}} In[3]:= Cases[X, {___, NA, ___}] Out[3]= {{8, NA, 20}, {-7, 9, NA}} Adriano Pascoletti 2009/2/16 Gregory Lypny > Hello everyone, > > Suppose I have the list > > X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}, > > where NA is a string, although it need not be. How can I use Select > to pull out all lists in X where NA appears in any element? In this > example, I want to pull out the second and third list. > > > Gregory > > > === Subject: Re: Select All Lists Where Any Element is a Given Value Select[X, MemberQ[#, NA] &] C.O. > Hello everyone, > > Suppose I have the list > > X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}, > > where NA is a string, although it need not be. How can I use Select > to pull out all lists in X where NA appears in any element? In this > example, I want to pull out the second and third list. > > > Gregory > > > -- Curtis Osterhoudt cfo@remove_this.lanl.and_this.gov PGP Key ID: 0x4DCA2A10 Please avoid sending me Word or PowerPoint attachments See http://www.gnu.org/philosophy/no-word-attachments.html === Subject: Select All Lists Where Any Element is a Given Value X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}; Select[X, MemberQ[#1, NA] & ] {{8, NA, 20}, {-7, 9, NA}} F.Jaccard ________________________________ De: Gregory Lypny [mailto:gregory.lypny@videotron.ca] =C0: mathgroup@smc.vnet.net Objet : Select All Lists Where Any Element is a Given Value Hello everyone, Suppose I have the list X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}, where NA is a string, although it need not be. How can I use Select to pull out all lists in X where NA appears in any element? In this example, I want to pull out the second and third list. Gregory === Subject: Re: Select All Lists Where Any Element is a Given Value X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}; Select[X, ! FreeQ[#, NA] &] {{8, NA, 20}, {-7, 9, NA}} Bobby > Hello everyone, > > Suppose I have the list > > X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}, > > where NA is a string, although it need not be. How can I use Select > to pull out all lists in X where NA appears in any element? In this > example, I want to pull out the second and third list. > > > Gregory > > -- DrMajorBob@longhorns.com === Subject: Select All Lists Where Any Element is a Given Value Hello everyone, Suppose I have the list X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}, where NA is a string, although it need not be. How can I use Select to pull out all lists in X where NA appears in any element? In this example, I want to pull out the second and third list. Gregory === Subject: Re: Select All Lists Where Any Element is a Given Value > Hello everyone, > > Suppose I have the list > > X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}, > > where NA is a string, although it need not be. How can I use Select > to pull out all lists in X where NA appears in any element? In this > example, I want to pull out the second and third list. > > > Gregory > > Try: Select[X, MemberQ[#, \NA\] &] Out={{8, \NA\, 20}, {-7, 9, \NA\}} -- _________________________________________________________________ Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Subject: Re: Select All Lists Where Any Element is a Given Value One more approach... Cases[X, {___, NA, ___}] > > Hello everyone, > > > Suppose I have the list > > > X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}, > > > where NA is a string, although it need not be. How can I use Select = > > to pull out all lists in X where NA appears in any element? In this = > > example, I want to pull out the second and third list. > > > > Gregory > > Try: > > Select[X, MemberQ[#, \NA\] &] > > Out={{8, \NA\, 20}, {-7, 9, \NA\}} > > -- > _________________________________________________________________ > Peter Breitfeld, Bad Saulgau, Germany --http://www.pBreitfeld.de === Subject: Re: Select All Lists Where Any Element is a Given Value Hi Gregory, try e.g.: Select[X, MemberQ[#, NA] &] hope this helps, Daniel > Hello everyone, > > Suppose I have the list > > X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}, > > where NA is a string, although it need not be. How can I use Select > to pull out all lists in X where NA appears in any element? In this > example, I want to pull out the second and third list. > > > Gregory > > === Subject: Re: Select All Lists Where Any Element is a Given Value > Hello everyone, > > Suppose I have the list > > X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}, > > where NA is a string, although it need not be. How can I use Select > to pull out all lists in X where NA appears in any element? In this > example, I want to pull out the second and third list. > > > Gregory Not really sure what you want, but this gives you all lists that don't contain NA: Select[X, FreeQ[#, NA] &] while this gives you all lists that do contain NA: Select[X, ! FreeQ[#, NA] &] the above look for the symbol NA, if you want the string \NA\, that will work just as well: Select[X, ! FreeQ[#, \NA\] &] and if you don't care whether its a string or a symbol: Select[X, ! FreeQ[#, \NA\ | NA] &] you should also consider to select depending on whether something does contain numeric data only, which is in many cases what one really wants and can be done with something like: Select[X, VectorQ[#, NumericQ] &] or Select[X, ! VectorQ[#, NumericQ] &] hth, albert === Subject: Re: Select All Lists Where Any Element is a Given Value > Hello everyone, > > Suppose I have the list > > X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}, > > where NA is a string, although it need not be. How can I use Select = > to pull out all lists in X where NA appears in any element? In this = > example, I want to pull out the second and third list. > > > Gregory Try this In[12]:= X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}; In[13]:= Select[X, ! FreeQ[#, NA] &] Out[13]= {{8, NA, 20}, {-7, 9, NA}} Sam === Subject: Re: Factor by Grouping xy is a symbol and is not the same as x*y or x y expr = 4 + 7 x*y - 14 y - 2 x 7 x y-2 x-14 y+4 expr // Factor (x-2) (7 y-2) expr // Simplify (x-2) (7 y-2) Bob Hanlon I am new to Mathmatica. I am trying to learn how to factor monomials and \ polynomials and at the same time learn Mathematica. How to I factoa equation \ such as 4+7xy-14y-2x I need to group to (x-2)(7y-2). Should be easy I think, but I can't actually figure out what the correct \ sequence would be. === Subject: Re: Scalar plot in 3D > Franco, > > Most of the color gradient functions have a scale that goes from 0 > to 1. For > precise control you can use ColorFunctionScaling -> False, and then > use > Rescale on the coloring variable to make it fit that domain. > > > David Park and a list { {u, v}->scalarValue }: ParametricPlot3D[ { {(R + r*Cos[v]) Sin[u], (R + r*Cos[v]) Cos[u], r*Sin[v]}}, {u, 0, 2 Pi}, {v, 0, 2 Pi}, ColorFunction -> Function[{x, y, z, u, v}, Hue[First[Nearest[vals, {v, u}]]]], ColorFunctionScaling -> False, Mesh -> 19, MeshStyle -> Gray ] I rescaled the field with Rescale[] as you suggested. Do you have any suggestion on how to improve this code? -- Franco Milicchio DiS - Dept. of Studies on Structures DIA - Dept. of Computer Science and Engineering University Roma Tre http://plm.dia.uniroma3.it/milicchio/ === Subject: Help with Mathematica 7.0 Hello All, In Mathematica 5.2 and earlier I could create a Notebook like: << Graphics` $FormatType = TraditionalForm; $TextStyle = {FontFamily -> \Times\, FontSize -> 12}; Strip = {Polygon[{{-0.1, 0, 1}, { 0.1, 0, 1}, {0.1, 0, 0} + s, {-0.1, 0, 0} + s}], Polygon[{{-0.1, 0, 0} + s, {-0.1, 0, -1}, {0.1, 0, -1}, {0.1, 0, 0} + s}]}; Magnet = {Cuboid[{-1, -0.5, -0.1}, {-0.2, 0.5, 0.1}], Cuboid[{0.2, -0.5, -0.1}, {1, 0.5, 0.1}]} Wire = {Line[{{0, 0, -1}, {0, 0, -1.2}, {-1.4, 0, -1.2}, {-1.4, 0, -0.2}}], Line[{{-1.2, 0, -0.2}, {-1.7, 0, -0.2}}], \\ Line[{{-1.3, 0, 0}, {-1.6, 0, 0}}], Line[{{-1.4, 0, 0}, {-1.4, 0, 1}, {-0.1, 0, 1}}]}; circuit = Table[ Show[Graphics3D[{Magnet, Strip, Wire}], Epilog -> {Text[\N\, {.402, .504}], Text[\S\, {.62, \\ .47}], Red, Arrow[{.53, .71}, {.53, .16}], Text[\Current\, {.7, 0.69 - .394t}]}, Boxed -> False, PlotRange -> {{-1.8, 1.5}, {-1, 1}, {-1.3, 1.3}}], {t, 0, 1, 0.05}]; Export[\Conductor.gif\, circuit, ConversionOptions -> {\Loop\ -> True}] to create animations as in \ http://web.me.com/timbrophy/physicsnow/currentm.html In versions 6 and 7 the Table command does not produce all the files I need for the animated gifs. How can I do the same? Manipulate is no good as I simply want gifs to demonstrate different aspects of Physics to my students. Tim Brophy === Subject: Re: Help with Mathematica 7.0 In my hurry I posted a file with errors in it. Sorry about that but it was picked up by so many of you that I am very impressed. I am really glad to be able to create animated gifs again. They are very useful in showing students something quickly. Tim >> Hello All, >> >> In Mathematica 5.2 and earlier I could create a Notebook like: >> >> << Graphics` >> $FormatType = TraditionalForm; >> $TextStyle = {FontFamily -> \Times\, FontSize -> 12}; >> Strip = {Polygon[{{-0.1, 0, 1}, { >> 0.1, 0, 1}, {0.1, 0, 0} + s, {-0.1, 0, 0} + s}], >> Polygon[{{-0.1, 0, 0} + s, {-0.1, >> 0, -1}, {0.1, 0, -1}, {0.1, 0, 0} + s}]}; >> Magnet = {Cuboid[{-1, -0.5, -0.1}, {-0.2, 0.5, 0.1}], >> Cuboid[{0.2, -0.5, -0.1}, {1, 0.5, 0.1}]} >> Wire = {Line[{{0, 0, -1}, {0, 0, -1.2}, {-1.4, 0, -1.2}, {-1.4, >> 0, -0.2}}], Line[{{-1.2, 0, -0.2}, {-1.7, 0, -= > 0.2}}], \\ >> Line[{{-1.3, 0, 0}, {-1.6, 0, 0}}], Line[{{-1.4, 0, 0}, {-1.4, 0, 1}, >> {-0.1, >> 0, 1}}]}; >> circuit = Table[ >> Show[Graphics3D[{Magnet, >> Strip, Wire}], Epilog -> {Text[\N\, {.402, .504}], Tex= > t[\S\, >> {.62, \\ >> .47}], Red, Arrow[{.53, .71}, {.53, .16}], >> Text[\Current\, {.7, 0.69 - .394t}]}, Boxe= > d -> False, >> PlotRange -> {{-1.8, 1.5}, {-1, >> 1}, {-1.3, 1.3}}], {t, 0, 1, 0.05}]; >> Export[\Conductor.gif\, circuit, ConversionOptions -> {\Loop\ -> >> True}] >> >> to create animations as in \ http://web.me.com/timbrophy/physicsnow/current= > m.html >> >> In versions 6 and 7 the Table command does not produce all the >> files I = > >> need for the animated gifs. How can I do the same? >> >> Manipulate is no good as I simply want gifs to demonstrate different >> aspects of Physics to my students. >> >> Tim Brophy > > I think this is one example of yours that works. There were several > typo's in this example - are you sure this worked in 5.2?? The Table > increment is t, but you use s as the value to add for the \strip\, and > you need to add the variable to just the \y\ component of the vector > (not the entire vector). And then it seems that the arrow is not > correct for the N and S locations, ... > > BTW animated GIF's are the default according to the GIF document page > in Mathematica now in V7 (so no need for the \ConversionOptions -> > {\Loop\ -> True}\ > > Also, if you want to see what it kinda looks like in Mathematica, just > add a \Show[circuit]\ command after the Export[] command. That is how > I figured out the problem that the variable should be added to just > the y vector component. > > I made the current arrow red, and the field arrow green, but change it > if you wish. > > Anyway here is what I came up with -- the gif file seems to display > correctly when I view it with Safari on a Mac > > $FormatType = TraditionalForm; > $TextStyle = {FontFamily -> \Times\, FontSize -> 12}; > Strip = {Polygon[{{-0.1, 0, 1}, {0.1, 0, 1}, {0.1, 0 + t, 0}, {-0.1, > 0 + t, 0}}], > Polygon[{{-0.1, 0 + t, 0}, {-0.1, 0, -1}, {0.1, 0, -1}, {0.1, > 0 + t, 0}}]}; > Magnet = {Cuboid[{-1, -0.5, -0.1}, {-0.2, 0.5, 0.1}], > Cuboid[{0.2, -0.5, -0.1}, {1, 0.5, 0.1}]}; > Wire = {Line[{{0, 0, -1}, {0, 0, -1.2}, {-1.4, 0, -1.2}, {-1.4, > 0, -0.2}}], Line[{{-1.2, 0, -0.2}, {-1.7, 0, -0.2}}], > Line[{{-1.3, 0, 0}, {-1.6, 0, 0}}], > Line[{{-1.4, 0, 0}, {-1.4, 0, 1}, {-0.1, 0, 1}}]}; > arrowacross = {Arrowheads[Large], > Arrow[{{0.8, .0, .2}, {-0.8, .0, .2}}]}; > arrowup = {Arrowheads[Large], > Arrow[{{0., -0.1, 1.}, {0., -0.1, -1.}}]}; > circuit = > Table[Show[ > Graphics3D[{Magnet, Strip, Wire, Thick, Green, arrowacross, Red, > arrowup}], > Epilog -> {Text[\S\, {.402, .504}], Text[\N\, {.62, .47}], Red, > Text[\Current\, {.7, 0.69 - .394 t}]}, Boxed -> False, > PlotRange -> {{-1.8, 1.5}, {-1, 1}, {-1.3, 1.3}}], {t, 0, 1, > 0.05}]; > Export[\Conductor.gif\, circuit]; > > -Bob > === Subject: Re: Help with Mathematica 7.0 > Hello All, > > In Mathematica 5.2 and earlier I could create a Notebook like: > > << Graphics` > $FormatType = TraditionalForm; > $TextStyle = {FontFamily -> \Times\, FontSize -> 12}; > Strip = {Polygon[{{-0.1, 0, 1}, { > 0.1, 0, 1}, {0.1, 0, 0} + s, {-0.1, 0, 0} + s}], > Polygon[{{-0.1, 0, 0} + s, {-0.1, > 0, -1}, {0.1, 0, -1}, {0.1, 0, 0} + s}]}; > Magnet = {Cuboid[{-1, -0.5, -0.1}, {-0.2, 0.5, 0.1}], > Cuboid[{0.2, -0.5, -0.1}, {1, 0.5, 0.1}]} > Wire = {Line[{{0, 0, -1}, {0, 0, -1.2}, {-1.4, 0, -1.2}, {-1.4, > 0, -0.2}}], Line[{{-1.2, 0, -0.2}, {-1.7, 0, -= 0.2}}], \\ > Line[{{-1.3, 0, 0}, {-1.6, 0, 0}}], Line[{{-1.4, 0, 0}, {-1.4, 0, 1}, > {-0.1, > 0, 1}}]}; > circuit = Table[ > Show[Graphics3D[{Magnet, > Strip, Wire}], Epilog -> {Text[\N\, {.402, .504}], Tex= t[\S\, > {.62, \\ > .47}], Red, Arrow[{.53, .71}, {.53, .16}], > Text[\Current\, {.7, 0.69 - .394t}]}, Boxe= d -> False, > PlotRange -> {{-1.8, 1.5}, {-1, > 1}, {-1.3, 1.3}}], {t, 0, 1, 0.05}]; > Export[\Conductor.gif\, circuit, ConversionOptions -> {\Loop\ -> \ True}] > > to create animations as \ inhttp://web.me.com/timbrophy/physicsnow/currentm= .html > > In versions 6 and 7 the Table command does not produce all the files I = > need for the animated gifs. How can I do the same? > > Manipulate is no good as I simply want gifs to demonstrate different > aspects of Physics to my students. > > Tim Brophy First, Mathematica's syntax coloring shows that the variable \s\ is not defined in your example, so give it a value. Second, when you look at the table of graphics you'll notice the pink background indicating there is an error. Mouse over the graphic to see the following error message in a tooltip: \Arrow argument should be a list of coordinates\ So change Arrow[{.53, .71}, {.53, .16}] to Arrow[{{.53, .71}, {.53, .16}}] Finally, when you export you'll see the message: \Export::convoptobs: ConversionOptions are obsolete. See the GIF format page for available options.\ and on the GIF format reference page in the help viewer you'll notice the appropriate option is AnimationRepititions. So change the Export call to: Export[\Conductor.gif\,circuit,AnimationRepetitions->\\[Infinity]] -Rob === Subject: Re: Help with Mathematica 7.0 Strip = With[{s = 0.0}, {Polygon[{{-0.1, 0, 1}, {0.1, 0, 1}, {0.1, 0, 0} + s, {-0.1, 0, 0} + s}], Polygon[{{-0.1, 0, 0} + s, {-0.1, 0, -1}, {0.1, 0, -1}, {0.1, 0, 0} + s}]}]; Magnet = {Cuboid[{-1, -0.5, -0.1}, {-0.2, 0.5, 0.1}], Cuboid[{0.2, -0.5, -0.1}, {1, 0.5, 0.1}]}; Wire = {Line[{{0, 0, -1}, {0, 0, -1.2}, {-1.4, 0, -1.2}, {-1.4, 0, -0.2}}], Line[{{-1.2, 0, -0.2}, {-1.7, 0, -0.2}}], Line[{{-1.3, 0, 0}, {-1.6, 0, 0}}], Line[{{-1.4, 0, 0}, {-1.4, 0, 1}, {-0.1, 0, 1}}]}; circuit = Table[Show[Graphics3D[{Magnet, Strip, Wire}], Epilog -> {Text[\N\, {.402, .504}], Text[\S\, {.62, .47}], Red, Arrow[{{.53, .71}, {.53, .16}}], Text[\Current\, {.7, 0.69 - .394 t}]}, Boxed -> False, PlotRange -> {{-1.8, 1.5}, {-1, 1}, {-1.3, 1.3}}], {t, 0, 1, 0.05}]; Export[\Conductor.gif\, circuit] ?? Jens > Hello All, > > In Mathematica 5.2 and earlier I could create a Notebook like: > > << Graphics` > $FormatType = TraditionalForm; > $TextStyle = {FontFamily -> \Times\, FontSize -> 12}; > Strip = {Polygon[{{-0.1, 0, 1}, { > 0.1, 0, 1}, {0.1, 0, 0} + s, {-0.1, 0, 0} + s}], > Polygon[{{-0.1, 0, 0} + s, {-0.1, > 0, -1}, {0.1, 0, -1}, {0.1, 0, 0} + s}]}; > Magnet = {Cuboid[{-1, -0.5, -0.1}, {-0.2, 0.5, 0.1}], > Cuboid[{0.2, -0.5, -0.1}, {1, 0.5, 0.1}]} > Wire = {Line[{{0, 0, -1}, {0, 0, -1.2}, {-1.4, 0, -1.2}, {-1.4, > 0, -0.2}}], Line[{{-1.2, 0, -0.2}, {-1.7, 0, -0.2}}], \\ > Line[{{-1.3, 0, 0}, {-1.6, 0, 0}}], Line[{{-1.4, 0, 0}, {-1.4, 0, 1}, > {-0.1, > 0, 1}}]}; > circuit = Table[ > Show[Graphics3D[{Magnet, > Strip, Wire}], Epilog -> {Text[\N\, {.402, .504}], Text[\S\, \ > {.62, \\ > .47}], Red, Arrow[{.53, .71}, {.53, .16}], > Text[\Current\, {.7, 0.69 - .394t}]}, Boxed -> False, > PlotRange -> {{-1.8, 1.5}, {-1, > 1}, {-1.3, 1.3}}], {t, 0, 1, 0.05}]; > Export[\Conductor.gif\, circuit, ConversionOptions -> {\Loop\ -> \ True}] > > to create animations as in \ http://web.me.com/timbrophy/physicsnow/currentm.html > > In versions 6 and 7 the Table command does not produce all the files I > need for the animated gifs. How can I do the same? > > Manipulate is no good as I simply want gifs to demonstrate different > aspects of Physics to my students. > > Tim Brophy > === Subject: Re: Help with Mathematica 7.0 > In versions 6 and 7 the Table command does not produce all the files I = > need for the animated gifs. How can I do the same? As of version 6 (no 7 here yet), you don't need (and shouldn't use) Graphics` anymore. Arrow is a part of the kernel now. Also, its syntax has changed, so you should now be writing Arrow[{{.53, .71}, {.53, .16}}] instead of Arrow[{.53, .71}, {.53, .16}] Also, you have the wrong variable in strip--it's written in terms of s, and your Table is iterating t! Also, I think just doing Export [\circuit.gif\, circuit] will do what you want there. Pillsy === Subject: Re: Help with Mathematica 7.0 > Hello All, > > In Mathematica 5.2 and earlier I could create a Notebook like: > > << Graphics` > $FormatType = TraditionalForm; > $TextStyle = {FontFamily -> \Times\, FontSize -> 12}; > Strip = {Polygon[{{-0.1, 0, 1}, { > 0.1, 0, 1}, {0.1, 0, 0} + s, {-0.1, 0, 0} + s}], > Polygon[{{-0.1, 0, 0} + s, {-0.1, > 0, -1}, {0.1, 0, -1}, {0.1, 0, 0} + s}]}; > Magnet = {Cuboid[{-1, -0.5, -0.1}, {-0.2, 0.5, 0.1}], > Cuboid[{0.2, -0.5, -0.1}, {1, 0.5, 0.1}]} > Wire = {Line[{{0, 0, -1}, {0, 0, -1.2}, {-1.4, 0, -1.2}, {-1.4, > 0, -0.2}}], Line[{{-1.2, 0, -0.2}, {-1.7, 0, -= 0.2}}], \\ > Line[{{-1.3, 0, 0}, {-1.6, 0, 0}}], Line[{{-1.4, 0, 0}, {-1.4, 0, 1}, > {-0.1, > 0, 1}}]}; > circuit = Table[ > Show[Graphics3D[{Magnet, > Strip, Wire}], Epilog -> {Text[\N\, {.402, .504}], Tex= t[\S\, > {.62, \\ > .47}], Red, Arrow[{.53, .71}, {.53, .16}], > Text[\Current\, {.7, 0.69 - .394t}]}, Boxe= d -> False, > PlotRange -> {{-1.8, 1.5}, {-1, > 1}, {-1.3, 1.3}}], {t, 0, 1, 0.05}]; > Export[\Conductor.gif\, circuit, ConversionOptions -> {\Loop\ -> \ True}] > > to create animations as in \ http://web.me.com/timbrophy/physicsnow/current= m.html > > In versions 6 and 7 the Table command does not produce all the files I = > need for the animated gifs. How can I do the same? > > Manipulate is no good as I simply want gifs to demonstrate different > aspects of Physics to my students. > > Tim Brophy I think this is one example of yours that works. There were several typo's in this example - are you sure this worked in 5.2?? The Table increment is t, but you use s as the value to add for the \strip\, and you need to add the variable to just the \y\ component of the vector (not the entire vector). And then it seems that the arrow is not correct for the N and S locations, ... BTW animated GIF's are the default according to the GIF document page in Mathematica now in V7 (so no need for the \ConversionOptions -> {\Loop\ -> True}\ Also, if you want to see what it kinda looks like in Mathematica, just add a \Show[circuit]\ command after the Export[] command. That is how I figured out the problem that the variable should be added to just the y vector component. I made the current arrow red, and the field arrow green, but change it if you wish. Anyway here is what I came up with -- the gif file seems to display correctly when I view it with Safari on a Mac $FormatType = TraditionalForm; $TextStyle = {FontFamily -> \Times\, FontSize -> 12}; Strip = {Polygon[{{-0.1, 0, 1}, {0.1, 0, 1}, {0.1, 0 + t, 0}, {-0.1, 0 + t, 0}}], Polygon[{{-0.1, 0 + t, 0}, {-0.1, 0, -1}, {0.1, 0, -1}, {0.1, 0 + t, 0}}]}; Magnet = {Cuboid[{-1, -0.5, -0.1}, {-0.2, 0.5, 0.1}], Cuboid[{0.2, -0.5, -0.1}, {1, 0.5, 0.1}]}; Wire = {Line[{{0, 0, -1}, {0, 0, -1.2}, {-1.4, 0, -1.2}, {-1.4, 0, -0.2}}], Line[{{-1.2, 0, -0.2}, {-1.7, 0, -0.2}}], Line[{{-1.3, 0, 0}, {-1.6, 0, 0}}], Line[{{-1.4, 0, 0}, {-1.4, 0, 1}, {-0.1, 0, 1}}]}; arrowacross = {Arrowheads[Large], Arrow[{{0.8, .0, .2}, {-0.8, .0, .2}}]}; arrowup = {Arrowheads[Large], Arrow[{{0., -0.1, 1.}, {0., -0.1, -1.}}]}; circuit = Table[Show[ Graphics3D[{Magnet, Strip, Wire, Thick, Green, arrowacross, Red, arrowup}], Epilog -> {Text[\S\, {.402, .504}], Text[\N\, {.62, .47}], Red, Text[\Current\, {.7, 0.69 - .394 t}]}, Boxed -> False, PlotRange -> {{-1.8, 1.5}, {-1, 1}, {-1.3, 1.3}}], {t, 0, 1, 0.05}]; Export[\Conductor.gif\, circuit]; -Bob === Subject: Re: Help with Mathematica 7.0 Hi Tim, it looks like version 7 does not allow \Arrow\ in an epilog. try,e.g.: Show[Graphics@Circle[], Epilog -> {Arrow[{0, 0}, 0.5 {1, 1}]}] I think this is a bug you should report to Wolfram. Daniel > Hello All, > > In Mathematica 5.2 and earlier I could create a Notebook like: > > << Graphics` > $FormatType = TraditionalForm; > $TextStyle = {FontFamily -> \Times\, FontSize -> 12}; > Strip = {Polygon[{{-0.1, 0, 1}, { > 0.1, 0, 1}, {0.1, 0, 0} + s, {-0.1, 0, 0} + s}], > Polygon[{{-0.1, 0, 0} + s, {-0.1, > 0, -1}, {0.1, 0, -1}, {0.1, 0, 0} + s}]}; > Magnet = {Cuboid[{-1, -0.5, -0.1}, {-0.2, 0.5, 0.1}], > Cuboid[{0.2, -0.5, -0.1}, {1, 0.5, 0.1}]} > Wire = {Line[{{0, 0, -1}, {0, 0, -1.2}, {-1.4, 0, -1.2}, {-1.4, > 0, -0.2}}], Line[{{-1.2, 0, -0.2}, {-1.7, 0, -0.2}}], \\ > Line[{{-1.3, 0, 0}, {-1.6, 0, 0}}], Line[{{-1.4, 0, 0}, {-1.4, 0, 1}, > {-0.1, > 0, 1}}]}; > circuit = Table[ > Show[Graphics3D[{Magnet, > Strip, Wire}], Epilog -> {Text[\N\, {.402, .504}], Text[\S\, \ > {.62, \\ > .47}], Red, Arrow[{.53, .71}, {.53, .16}], > Text[\Current\, {.7, 0.69 - .394t}]}, Boxed -> False, > PlotRange -> {{-1.8, 1.5}, {-1, > 1}, {-1.3, 1.3}}], {t, 0, 1, 0.05}]; > Export[\Conductor.gif\, circuit, ConversionOptions -> {\Loop\ -> \ True}] > > to create animations as in \ http://web.me.com/timbrophy/physicsnow/currentm.html > > In versions 6 and 7 the Table command does not produce all the files I > need for the animated gifs. How can I do the same? > > Manipulate is no good as I simply want gifs to demonstrate different > aspects of Physics to my students. > > Tim Brophy > === Subject: Re: Help with Mathematica 7.0 I just learned that the syntax of Arrow has changed. The following works: Show[Graphics@Circle[], Epilog -> {Arrow[{{0, 0}, 0.5 {1, 1}}]}] Daniel > Hi Tim, > > it looks like version 7 does not allow \Arrow\ in an epilog. try,e.g.: > > Show[Graphics@Circle[], Epilog -> {Arrow[{0, 0}, 0.5 {1, 1}]}] > > I think this is a bug you should report to Wolfram. > > Daniel > > > > >> Hello All, > > >> In Mathematica 5.2 and earlier I could create a Notebook like: > > >> << Graphics` > >> $FormatType = TraditionalForm; > >> $TextStyle = {FontFamily -> \Times\, FontSize -> 12}; > >> Strip = {Polygon[{{-0.1, 0, 1}, { > >> 0.1, 0, 1}, {0.1, 0, 0} + s, {-0.1, 0, 0} + s}], > >> Polygon[{{-0.1, 0, 0} + s, {-0.1, > >> 0, -1}, {0.1, 0, -1}, {0.1, 0, 0} + s}]}; > >> Magnet = {Cuboid[{-1, -0.5, -0.1}, {-0.2, 0.5, 0.1}], > >> Cuboid[{0.2, -0.5, -0.1}, {1, 0.5, 0.1}]} > >> Wire = {Line[{{0, 0, -1}, {0, 0, -1.2}, {-1.4, 0, -1.2}, {-1.4, > >> 0, -0.2}}], Line[{{-1.2, 0, -0.2}, {-1.7, 0, -0.2}}], \\ > >> Line[{{-1.3, 0, 0}, {-1.6, 0, 0}}], Line[{{-1.4, 0, 0}, {-1.4, 0, 1}, > >> {-0.1, > >> 0, 1}}]}; > >> circuit = Table[ > >> Show[Graphics3D[{Magnet, > >> Strip, Wire}], Epilog -> {Text[\N\, {.402, .504}], Text[\S\, \ > >> {.62, \\ > >> .47}], Red, Arrow[{.53, .71}, {.53, .16}], > >> Text[\Current\, {.7, 0.69 - .394t}]}, Boxed -> False, > >> PlotRange -> {{-1.8, 1.5}, {-1, > >> 1}, {-1.3, 1.3}}], {t, 0, 1, 0.05}]; > >> Export[\Conductor.gif\, circuit, ConversionOptions -> {\Loop\ -> \ True}] > > >> to create animations as in \ http://web.me.com/timbrophy/physicsnow/currentm.html > > >> In versions 6 and 7 the Table command does not produce all the files I > >> need for the animated gifs. How can I do the same? > > >> Manipulate is no good as I simply want gifs to demonstrate different > >> aspects of Physics to my students. > > >> Tim Brophy > > > > === Subject: Re: BarChart3D with Ticks-option in Mathematica 7 > Probably this is a bug ofBarChart3D. > HoweverBarChart3Dreturns a Graphics3D object, therefore you can go > around the bug by using the following code: > > Show[BarChart3D[{{0.6, 0}, {0, -0.3}}, ChartLayout -> \Grid\, > AxesEdge -> {{0, 0}, {1, 0}, Automatic}], > Ticks -> {{{1, \1\, {0.001`, 0}}, {2, \2\, {0.001`, 0}}}, {{1, > \1\, {0.001`, 0}}, {2, \2\, {0.001`, 0}}}, Automatic}] > > Not neat, but it works. > Dario I've received an E-Mail from someone from Wolfram who told me, that the problem will be fixed in the next release. Lars === Subject: contract selection in front end Many times I use shift-arrow to expand my selection in the user interface but accidentally overshoot. In other text editors, I can back up using the other arrow key. But in mathematica, this expands the selection on the other side! Does anyone know how to contract a selection? === Subject: Exporting a bitmap in native resolution HI all, first I must mention that I am still on 5.2, but I suspect the problem is universal. I have a ListDensityPlot which I want to export as a bitmap (e.g., png) in native resolution, that is each data point yielding one pixel. Anybody figured out how to do that? === Subject: Re: Exporting a bitmap in native resolution take the data from the DensityGraphics and use ImageMatrixQ[bm_?MatrixQ] := True ImageMatrixQ[bm_?(MatrixQ[#, VectorQ] &)] := True ImageMatrixQ[_] := False MatrixToImage[data_?ImageMatrixQ] := Module[{dim, ny, nx, ch, mind, maxd, colorf}, dim = Dimensions[data]; {ny, nx} = Take[dim, 2]; If[3==Length[dim], ch = Last[dim], ch = 1 ]; colorf = Switch[ch, 1, GrayLevel, 2, GrayLevel, 3, RGBColor, 4, RGBColor ]; {mind, maxd} = {Min[#], Max[#]} &[Flatten[data]]; If[Sqrt[#.#]&[{mind,maxd}-Round[{mind,maxd}]]<$MachineEpsilon, {mind, maxd}=Round[{mind, maxd}] ]; If[Abs[maxd-mind]<$MachineEpsilon, maxd=mind+1 ]; Graphics[ Raster[ Developer`ToPackedArray[data], {{0, 0}, {nx, ny}}, {mind, maxd}, ColorFunction -> colorf ], AspectRatio -> Automatic, PlotRange -> {{0, nx}, {0, ny}}, ImageSize -> {nx, ny} ] ] the MatrixToImage[] function above. Jens > HI all, > first I must mention that I am still on 5.2, but I suspect the problem > is universal. I have a ListDensityPlot which I want to export as a > bitmap (e.g., png) in native resolution, that is each data point > yielding one pixel. > Anybody figured out how to do that? > > === Subject: Re: PlotStyle will not distribute over Table Attributes[Plot] {HoldAll,Protected} Since Plot has Attribute HoldAll, at the time PlotStyle gets evaluated there \ is a single entity (a Table) to Plot. Use Evaluate on the Table to force its \ evaluation earlier. Plot[Evaluate[Table[Sin[a x], {a, 1, 2}]], {x, 0, Pi}, PlotStyle -> {Hue[0.7], Hue[1]}] Bob Hanlon I create several functions using Table and want to plot them on the same plot with different styles. However, it seems that the last style in the list of PlotStyle options is used for all the lines. E.g. Plot[Table[Sin[a x], {a, 1, 2}], {x, 0, Pi}, PlotStyle -> {Hue[0.7], Hue[1]}] will have both lines with red color, while Plot[{Sin[ x], Sin[2 x]} , {x, 0, Pi}, PlotStyle -> {Hue[0.7], Hue[1]}] works correctly. Any idea how to make first version work? (I have Mathematica 6.0) Kresimir -- Bob Hanlon === Subject: Re: pfa2pfb On 17 Feb, 11:25, Jens-Peer Kuska > > that is nonsense, dvips work with binary *.pfb and ASCII > PostScript fonts. Just find the font map file for dvips > that comes with you Mathematica and add the texmf root > that is part of the Mathematica distribution to the > texmf roots that your TeX system searches. > > If you have MikTeX or teTeX fin the fontname/wolfram.map > in the TeX installation root and delete it. > This file is a false font map file, I have reported it several > times to the developers but they had other things to do than > to replace the file with the correct one that comes with > Mathematica. > > Jens well. It doesn't have the offending wolfram.map in it, so perhaps the teTex maintainers have at last responded to your complaints. You say \Just find the font map file for dvips that comes with your Mathematica\. I know exactly where this is, but what am I supposed to do with the information? Please excuse me if I have misunderstood what you have told me. Surely it wouldn't work to just add Mathematica's wolfram.map to my teTeX files at the appropriate place, because the various programs will still not know where the fonts are to be found. You say (or at least I think this is what you are saying) that I should add the texmf tree provided by Mathematica to my own texmf tree. I'm a bit reluctant to do so, as later downloads of teTex from MacPorts will overwrite (and delete) any such addition. The good alternatives seem to me to be: 1. Change some configuration file in the teTex distribution to enable searching in Mathematica's texmf. Which configuration file, and what is the minimal change needed? I would then keep a copy of the changed configuration file in my home directory, and a diff with the original, so that I can easily maintain any changes I make when packages are updated. 2. Make a symbolic link /opt/local/share/texmf/MmaTexmf -> Mathematica's texmf. Will this work? 3. Maybe tex and its cousins already search my $HOME/texmf. In this case I can just copy Mathematica's texmf to the texmf I already have in my home directory. I have a vague memory of editing some configuration file so that this would be done, but I've forgotten which one. Any suggestions? Should I then update updmap.cfg and run updmap? If I have to update updmap.cfg, precisely what changes are needed? And what about texhash? Should that be run with any arguments or flags? And then I would want to check that I have done things correctly by using kpsewhich. However, in teTex, and presumably in other modern packages of TeX and its cousins, environmental variables seem to be defined only once one invokes tex or latex or whatever. The result is that kpsewhich givees a null response to almost any command. What arguments or flags are required to make kpsewhich give the right answers? Sorry to ask so many questions, but I have been struggling for some time ineffectually to find out what to do. David === Subject: Re: pfa2pfb On 20 Feb, 10:47, Jens-Peer Kuska > > in Mathematica 5.2,6.0 and 7.0 the TEXMF root for you is at: > > $TopDirectory/SystemFiles/IncludeFiles/TeX/texmf > > Add this to the TEXMF roots of your teTeX. > teTeX uses typical an environment variable for that and finaly > rehash it, to update the data base. I did this by editing my texmf.cnf. Here is the result: % kpsewhich -expand-var='$TEXMF' {!!/Users/dbae/.texmf-config,!!/Users/dbae/.texmf-var,/Users/dbae/ texmf,/Applications/Mathematica\\ 5.2.app/SystemFiles/IncludeFiles/TeX/ texmf,!!/opt/local/share/texmf-config,!!/opt/local/share/texmf-var,!!/ opt/local/share/texmf,!!/opt/local/share/texmf-local,!!/opt/local/ share/texmf-dist} Note that the Mathematica texmf has a space in the directory name. I dealt with this by putting some number of backslashes into the entry for Mathematica's texf in texmf.cnf. I hope that kpsewhich's report is what should be expected. > and the map file is at > > $TopDirectory/SystemFiles/IncludeFiles/TeX/texmf/dvips/config/wolfram.map Yes, I see the two map files, but I don't know how to use this information. I ran updmap as root, thinking this would fix the situation. However, when I run dvips on the relevant dvi file, I still get the error message dvips: Font Mathematica2Mono used in file 232.eps is not in the mapping file. Am I supposed to edit updmap.cfg by hand? But it's not clear to me what to put into updmap.cfg. None of the map file names in updmap.cfg seem to be qualified by their pathnames. So how does dvips get this information? Am I supposed to run updmap after editiing updmap.cfg? And then texhash?? David === Subject: Re: pfa2pfb you have also a dvips config and it must contain the additional map file % An \all-in-one\ psfonts.map. p psfonts.map % and the LaserWriter 35 fonts *not* in Acrobat. pdftex loads % these differently p +lw35extra.mapfile p +wolfram.map Jens > On 20 Feb, 10:47, Jens-Peer Kuska >> >> in Mathematica 5.2,6.0 and 7.0 the TEXMF root for you is at: >> >> $TopDirectory/SystemFiles/IncludeFiles/TeX/texmf >> >> Add this to the TEXMF roots of your teTeX. >> teTeX uses typical an environment variable for that and finaly >> rehash it, to update the data base. > > I did this by editing my texmf.cnf. Here is the result: > > % kpsewhich -expand-var='$TEXMF' > {!!/Users/dbae/.texmf-config,!!/Users/dbae/.texmf-var,/Users/dbae/ > texmf,/Applications/Mathematica\\ 5.2.app/SystemFiles/IncludeFiles/TeX/ > texmf,!!/opt/local/share/texmf-config,!!/opt/local/share/texmf-var,!!/ > opt/local/share/texmf,!!/opt/local/share/texmf-local,!!/opt/local/ > share/texmf-dist} > > Note that the Mathematica texmf has a space in the directory name. I > dealt with this by putting some number of backslashes into the entry > for Mathematica's texf in texmf.cnf. I hope that kpsewhich's report > is what should be expected. > >> and the map file is at >> >> \ $TopDirectory/SystemFiles/IncludeFiles/TeX/texmf/dvips/config/wolfram.map > > Yes, I see the two map files, but I don't know how to use this > information. I ran updmap as root, thinking this would fix the > situation. However, when I run dvips on the relevant dvi file, > I still get the error message dvips: Font Mathematica2Mono used > in file 232.eps is not in the mapping file. > > Am I supposed to edit updmap.cfg by hand? But it's not clear to me > what to put into updmap.cfg. None of the map file names in updmap.cfg > seem to be qualified by their pathnames. So how does dvips get this > information? > > Am I supposed to run updmap after editiing updmap.cfg? And then > texhash?? > > David > === Subject: Re: pfa2pfb > On 17 Feb, 11:25, Jens-Peer Kuska >> >> that is nonsense, dvips work with binary *.pfb and ASCII >> PostScript fonts. Just find the font map file for dvips >> that comes with you Mathematica and add the texmf root >> that is part of the Mathematica distribution to the >> texmf roots that your TeX system searches. >> >> If you have MikTeX or teTeX fin the fontname/wolfram.map >> in the TeX installation root and delete it. >> This file is a false font map file, I have reported it several >> times to the developers but they had other things to do than >> to replace the file with the correct one that comes with >> Mathematica. >> >> Jens > > well. It doesn't have the offending wolfram.map in it, so perhaps the > teTex maintainers have at last responded to your complaints. > > You say \Just find the font map file for dvips that comes with your > Mathematica\. I know exactly where this is, but what am I supposed to > do with the information? > > Please excuse me if I have misunderstood what you have told me. Surely > it wouldn't work to just add Mathematica's wolfram.map to my teTeX > files at the appropriate place, because the various programs will > still not know where the fonts are to be found. > > You say (or at least I think this is what you are saying) that I > should add the texmf tree provided by Mathematica to my own texmf > tree. I'm a bit reluctant to do so, as later downloads of teTex from > MacPorts will overwrite (and delete) any such addition. The good > alternatives seem to me to be: > 1. Change some configuration file in the teTex distribution to enable > searching in Mathematica's texmf. Which configuration file, and what > is the minimal change needed? I would then keep a copy of the changed > configuration file in my home directory, and a diff with the original, > so that I can easily maintain any changes I make when packages are > updated. > 2. Make a symbolic link /opt/local/share/texmf/MmaTexmf -> > Mathematica's texmf. Will this work? > 3. Maybe tex and its cousins already search my $HOME/texmf. In this > case I can just copy Mathematica's texmf to the texmf I already have > in my home directory. I have a vague memory of editing some > configuration file so that this would be done, but I've forgotten > which one. Any suggestions? > > Should I then update updmap.cfg and run updmap? If I have to update > updmap.cfg, precisely what changes are needed? And what about texhash? > Should that be run with any arguments or flags? > > And then I would want to check that I have done things correctly by > using kpsewhich. However, in teTex, and presumably in other modern > packages of TeX and its cousins, environmental variables seem to be > defined only once one invokes tex or latex or whatever. The result is > that kpsewhich givees a null response to almost any command. What > arguments or flags are required to make kpsewhich give the right > answers? > > Sorry to ask so many questions, but I have been struggling for some > time ineffectually to find out what to do. > > David > I'm using tex and Mathematica on Mac too. All seems to work since I did the following steps: In $HOMETEXMF, which is $HOME/Library/texmf, go to the subdirectories fonts/afm, fonts/tfm, fonts/type1 and fonts/vf. In each of these directories add a symlink pointing to the corresponding directory (afm, tfm,...): Mathematica.app/SystemFiles/IncludeFiles/TeX/texmf/fonts//wolfram Make another symlink in the directory fonts/map/dvips/misc/wolfram.map which points to Mathematica.app/SystemFiles/IncludeFiles/TeX/texmf/dvips/config/wolfram.map Now make sure, the wolfram.map is active in your updmap. Use updmap --edit as admin for that. No need to run texhash on Mac for files in $HOMETEXMF, TeX will search $HOMTEXMF first. To make Ghostscript know about the Mathematica-Fonts I added the paths /Applications/Mathematica.app/SystemFiles/Fonts/Type1 and /Applications/Mathematica.app/SystemFiles/IncludeFiles/ TeX/texmf/fonts/type1/wolfram to the environment variable GS_FONTPATH in my .bashrc Hope I could help -- _________________________________________________________________ Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de === Subject: Re: pfa2pfb in Mathematica 5.2,6.0 and 7.0 the TEXMF root for you is at: $TopDirectory/SystemFiles/IncludeFiles/TeX/texmf Add this to the TEXMF roots of your teTeX. teTeX uses typical an environment variable for that and finaly rehash it, to update the data base. and the map file is at $TopDirectory/SystemFiles/IncludeFiles/TeX/texmf/dvips/config/wolfram.map the map file for pdftex is in $TopDirectory/SystemFiles/IncludeFiles/TeX/texmf/pdftex/config/pdfwolfram.ma\ p Jens > On 17 Feb, 11:25, Jens-Peer Kuska >> >> that is nonsense, dvips work with binary *.pfb and ASCII >> PostScript fonts. Just find the font map file for dvips >> that comes with you Mathematica and add the texmf root >> that is part of the Mathematica distribution to the >> texmf roots that your TeX system searches. >> >> If you have MikTeX or teTeX fin the fontname/wolfram.map >> in the TeX installation root and delete it. >> This file is a false font map file, I have reported it several >> times to the developers but they had other things to do than >> to replace the file with the correct one that comes with >> Mathematica. >> >> Jens > > well. It doesn't have the offending wolfram.map in it, so perhaps the > teTex maintainers have at last responded to your complaints. > > You say \Just find the font map file for dvips that comes with your > Mathematica\. I know exactly where this is, but what am I supposed to > do with the information? > > Please excuse me if I have misunderstood what you have told me. Surely > it wouldn't work to just add Mathematica's wolfram.map to my teTeX > files at the appropriate place, because the various programs will > still not know where the fonts are to be found. > > You say (or at least I think this is what you are saying) that I > should add the texmf tree provided by Mathematica to my own texmf > tree. I'm a bit reluctant to do so, as later downloads of teTex from > MacPorts will overwrite (and delete) any such addition. The good > alternatives seem to me to be: > 1. Change some configuration file in the teTex distribution to enable > searching in Mathematica's texmf. Which configuration file, and what > is the minimal change needed? I would then keep a copy of the changed > configuration file in my home directory, and a diff with the original, > so that I can easily maintain any changes I make when packages are > updated. > 2. Make a symbolic link /opt/local/share/texmf/MmaTexmf -> > Mathematica's texmf. Will this work? > 3. Maybe tex and its cousins already search my $HOME/texmf. In this > case I can just copy Mathematica's texmf to the texmf I already have > in my home directory. I have a vague memory of editing some > configuration file so that this would be done, but I've forgotten > which one. Any suggestions? > > Should I then update updmap.cfg and run updmap? If I have to update > updmap.cfg, precisely what changes are needed? And what about texhash? > Should that be run with any arguments or flags? > > And then I would want to check that I have done things correctly by > using kpsewhich. However, in teTex, and presumably in other modern > packages of TeX and its cousins, environmental variables seem to be > defined only once one invokes tex or latex or whatever. The result is > that kpsewhich givees a null response to almost any command. What > arguments or flags are required to make kpsewhich give the right > answers? > > Sorry to ask so many questions, but I have been struggling for some > time ineffectually to find out what to do. > > David > === Subject: Copying and Pasting and Inline Cells One thing that I find quite annoying about Version 7 is that the regular copy and paste functions from the context menu no longer work in many situations. I'm so used to using the context menu that I keep falling into this trap. Then Helen Read kindly and patiently reminds me that I should \ use Ctrl-C and Ctrl-V instead and that appears to work properly. But both methods should work equally well and I hope this behavior is restored in \ the next update. One feature of Inline Cells is that they have the characteristic ShowStringCharacters -> True. But I consider an Inline Cell as more or less equivalent to an Input or Output Cell. After all, they can be evaluated. So why shouldn't they have the same characteristics as Input/Output cells, and specifically have ShowStringCharacters -> False? David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ === Subject: Re: Copying and Pasting and Inline Cells > One thing that I find quite annoying about Version 7 is that the regular > copy and paste functions from the context menu no longer work in many > situations. I'm so used to using the context menu that I keep falling \ into > this trap. Then Helen Read kindly and patiently reminds me that I should \ use > Ctrl-C and Ctrl-V instead and that appears to work properly. But both > methods should work equally well and I hope this behavior is restored in \ the > next update. I agree that this needs fixing. Even when copy from the context menu works, it's often darn difficult to get the mouse in precisely the right spot so that copy remains enabled. -- Helen Read University of Vermont === Subject: NMinimize causes kernel crash in 7.0 I am doing the following: NMinimize[ If[NumericTensorQ[{A, B, S1, S2}], energy[A, B, {S1, S2}], Hold[energy[A, B, {S1, S2}]]], Flatten[Join[A, B, S1, S2]], Method -> \NelderMead\] where NumericTensorQ[a_List] := And @@ Map[NumericQ, Flatten[a]] A, B, S1 and S2 have 80 parameters and the energy function does not consume a lot of memory. It is a relatively complicated numerical function but should in principle be quadratic in the parameters. The system monitor shows the memory consumption more or less constant during the evaluation. After about 150 evaluations the kernel crashes. I am using Mathematica version 7.0 Sebastian === Subject: Dynamic Module with Trigger In the toy DynamicModule below pressing the trigger makes an existing line longer. The initial length of the line is controlled by a slider. The module works but I want to add the feature that when I move the slider the trigger resets itself and the now changed initial line is drawn. Is it possible to do this? Hugh Goyder DynamicModule[ {a = 3, b}, b = 2; Column[{ Slider[Dynamic[a], {0, 10, 1}], Trigger[Dynamic[b, (b = #; b = b + a) &], {0, 25}], Row[{Dynamic[{a, b}]}], Graphics[{Dynamic[Line[{{0, 0}, {b, 0}}]]}, PlotRange -> {{0, 40}, {-10, 10}}, Frame -> True, ImageSize -> 72 6] }] ] === Subject: Re: Dynamic Module with Trigger Hugh, I'm not certain if I understand your objective. Why don't you draw your \ line from zero to a + b, and keep b 'pure'? The following uses the slider to readjust a and adjusts the existing line for the new value of a. DynamicModule[ {a = 3, b = 0}, Column[ {Slider[Dynamic[a], {0, 10, 1}], Trigger[Dynamic[b], {0, 25}], Row[{Dynamic[{a, a + b}]}], Graphics[ {Dynamic[Line[{{0, 0}, {a + b, 0}}]]}, PlotRange -> {{0, 40}, {-10, 10}}, Frame -> True, ImageSize -> 72 6]}]] On the other hand, the following uses the slider to adjust a and sets b to zero. DynamicModule[ {a = 3, b = 0}, Column[ {Slider[Dynamic[a, (a = #; b = 0) &], {0, 10, 1}], Trigger[Dynamic[b], {0, 25}], Row[{Dynamic[{a, a + b}]}], Graphics[ {Dynamic[Line[{{0, 0}, {a + b, 0}}]]}, PlotRange -> {{0, 40}, {-10, 10}}, Frame -> True, ImageSize -> 72 6]}]] Also, I wouldn't initialize b to anything other than zero or the initial value of the Trigger. David Park djmpark@comcast.net http://home.comcast.net/~djmpark/ In the toy DynamicModule below pressing the trigger makes an existing line longer. The initial length of the line is controlled by a slider. The module works but I want to add the feature that when I move the slider the trigger resets itself and the now changed initial line is drawn. Is it possible to do this? Hugh Goyder DynamicModule[ {a = 3, b}, b = 2; Column[{ Slider[Dynamic[a], {0, 10, 1}], Trigger[Dynamic[b, (b = #; b = b + a) &], {0, 25}], Row[{Dynamic[{a, b}]}], Graphics[{Dynamic[Line[{{0, 0}, {b, 0}}]]}, PlotRange -> {{0, 40}, {-10, 10}}, Frame -> True, ImageSize -> 72 6] }] ] === Subject: Re: Dynamic Module with Trigger I am probably making my own problem too complicated. After posting I came up with an adequate solution whereby I add another variable and use a second argument in Dynamic for setting the initial condition. This works, as shown below. The only difficulty is that if the trigger is interrupted while operating it does not stop and reset. Hugh Goyder DynamicModule[{a = 3, b, c = 0}, b = 2; Column[{Slider[Dynamic[a, (a = #; c = a) &], {0, 10, 1}], Trigger[Dynamic[b, (b = #; c = b + a) &], {0, 25}], Row[{Dynamic[{a, b}]}], Graphics[{Dynamic[Line[{{0, 0}, {c, 0}}]]}, PlotRange -> {{0, 40}, {-10, 10}}, Frame -> True, ImageSize -> 72 6]}]] > In the toy DynamicModule below pressing the trigger makes an existing > line longer. The initial length of the line is controlled by a slider. > The module works but I want to add the feature that when I move the > slider the trigger resets itself and the now changed initial line is > drawn. Is it possible to do this? > > Hugh Goyder > > DynamicModule[ > {a = 3, b}, > b = 2; > Column[{ > Slider[Dynamic[a], {0, 10, 1}], > Trigger[Dynamic[b, (b = #; b = b + a) &], {0, 25}], > Row[{Dynamic[{a, b}]}], > Graphics[{Dynamic[Line[{{0, 0}, {b, 0}}]]}, > PlotRange -> {{0, 40}, {-10, 10}}, Frame -> True, > ImageSize -> 72 6] > }] > ] === Subject: Re: Dynamic Module with Trigger > In the toy DynamicModule below pressing the trigger makes an existing > line longer. The initial length of the line is controlled by a slider. > The module works but I want to add the feature that when I move the > slider the trigger resets itself and the now changed initial line is > drawn. Is it possible to do this? > > DynamicModule[ > {a = 3, b}, > b = 2; > Column[{ > Slider[Dynamic[a], {0, 10, 1}], > Trigger[Dynamic[b, (b = #; b = b + a) &], {0, 25}], > Row[{Dynamic[{a, b}]}], > Graphics[{Dynamic[Line[{{0, 0}, {b, 0}}]]}, > PlotRange -> {{0, 40}, {-10, 10}}, Frame -> True, > ImageSize -> 72 6] > }] > ] Is this what you are looking for? DynamicModule[{a = 3, b}, b = 2; Column[{Slider[Dynamic[a, (b = a = #) &], {0, 10, 1}], Trigger[Dynamic[b, (b = #; b = b + a) &], {0, 25}], Row[{Dynamic[{a, b}]}], Graphics[{Dynamic[Line[{{0, 0}, {b, 0}}]]}, PlotRange -> {{0, 40}, {-10, 10}}, Frame -> True, ImageSize -> 72 6]}]] albert === Subject: Re: Help with Mathematica 7.0 >it looks like version 7 does not allow \Arrow\ in an epilog. >try,e.g.: >Show[Graphics@Circle[], Epilog -> {Arrow[{0, 0}, 0.5 {1, 1}]}] >I think this is a bug you should report to Wolfram. There is no bug here. The problem is incorrect arguments being supplied to Arrow. Try: Show[Graphics@Circle[], Epilog -> {Arrow[{{0, 0}, {1, 1}}, .5]}] === Subject: Stylesheets I've written some cascaded style sheets for some of my notes. If I want to distribute the notebooks to someone else I have two options: 1. Give them my set of style sheets and have them 'install' them... 2. Put the style definitions into the notebook. Now option 1 is not always so easy to explain to people. The only way I know to do option 2 is to open up the notebook as text... eg in a text editor and replace the term StyleDefinitions- >\MyStyle.nb\ with StyleDefinitions->Notebook[{...}] where the ... is all of the StyleData objects contained in \MyStyle.nb\. Admittedly, this is just a simple copy-paste action, but it seems rather inelegant (and tiresome if you have to do it too often). Finally to my question: Is there an equivalent frontend procedure? Simon === Subject: Re: Stylesheets David Reiss' answer is pretty much what I needed/wanted. So for a one line solution from within the notebook I want to modify, I just need to enter: SetOptions[EvaluationNotebook[], StyleDefinitions -> Get[HomeDirectory[] <> \/.Mathematica/SystemFiles/FrontEnd/StyleSheets/MyStyle.nb\]] The 'embed stylesheet' that Helen says used to be in the menu (I don't have any previous versions to check on) sounds like what I wanted. Simon === Subject: Re: Stylesheets and of course, using cascaded style sheets, a kludge like the following works: ssDir = HomeDirectory[] <> \/.Mathematica/SystemFiles/FrontEnd/StyleSheets/\; ss = Get[ssDir <> \/MySlideShow.nb\] /. Cell[StyleData[StyleDefinitions -> \MyBase.nb\]] -> Sequence@@Get[ssDir <> \/MyBase.nb\][[1, 1]]; SetOptions[EvaluationNotebook[], StyleDefinitions -> ss] of course, one could write a procedure which would follow the StyleDefinitions->\*.nb\ links all the way down to \default.nb\ or \base.nb\ if need be. === Subject: Re: Stylesheets > > I've written some cascaded style sheets for some of my notes. > If I want to distribute the notebooks to someone else I have two > options: > 1. Give them my set of style sheets and have them 'install' them... > 2. Put the style definitions into the notebook. > > Now option 1 is not always so easy to explain to people. > > The only way I know to do option 2 is to open up the notebook as > text... eg in a text editor and replace the term StyleDefinitions- >> \MyStyle.nb\ with StyleDefinitions->Notebook[{...}] where the ... is > all of the StyleData objects contained in \MyStyle.nb\. > Admittedly, this is just a simple copy-paste action, but it seems > rather inelegant (and tiresome if you have to do it too often). > > Finally to my question: > Is there an equivalent frontend procedure? What I normally do is begin with a plain notebook, edit the stylesheet as desired, and save the file. Then I just open up this file (or one that came from a copy of it), rename it, and delete the contents and put in the new content. This is rather inelegant as well, but it's easy. IIRC, there used to be an \embed stylesheet\ option on the menu somewhere under Format. Not sure why they removed that. -- Helen Read University of Vermont === Subject: Re: Stylesheets Simon, Using Preferenences you could even make you style sheet your default style sheet. To put your styles in the Notes that you send to other people: 1) With your notebook open select Menu > Format > Edit Style Sheet. 2) You will obtain a Private Style Definitions for your notes that has a single line saying it is inheriting base definition from stylesheet \MyStyle.nb\. 3) The line will also have a link. Click on the link to obtain Private \ Style Definitions For MyStyle.nb. 4) Now select all the cells in MyStyle.nb, use Ctrl-C to copy them and then use Ctrl-V to REPLACE the single line in the original Notes style sheet. \ The notebook will now contain a private copy of all your styles. There is one catch - you must use Ctrl-C and Ctrl-V and you cannot use the copy and paste items on the context menu. This is a bug that may not get fixed for a while. I've written some cascaded style sheets for some of my notes. If I want to distribute the notebooks to someone else I have two options: 1. Give them my set of style sheets and have them 'install' them... 2. Put the style definitions into the notebook. Now option 1 is not always so easy to explain to people. The only way I know to do option 2 is to open up the notebook as text... eg in a text editor and replace the term StyleDefinitions- >\MyStyle.nb\ with StyleDefinitions->Notebook[{...}] where the ... is all of the StyleData objects contained in \MyStyle.nb\. Admittedly, this is just a simple copy-paste action, but it seems rather inelegant (and tiresome if you have to do it too often). Finally to my question: Is there an equivalent frontend procedure? Simon === Subject: Re: Stylesheets if nb is the NotebookObject of the notebook that you want to embed these style definitions in then execute SetOptions[nb, StyleDefinitions->Notebook[{...}] ] will do the trick. -David > > I've written some cascaded style sheets for some of my notes. > If I want to distribute the notebooks to someone else I have two > options: > 1. Give them my set of style sheets and have them 'install' them... > 2. Put the style definitions into the notebook. > > Now option 1 is not always so easy to explain to people. > > The only way I know to do option 2 is to open up the notebook as > text... eg in a text editor and replace the term \ StyleDefinitions->\MySty= le.nb\ with StyleDefinitions->Notebook[{...}] where the ... is > > all of the StyleData objects contained in \MyStyle.nb\. > Admittedly, this is just a simple copy-paste action, but it seems > rather inelegant (and tiresome if you have to do it too often). > > Finally to my question: > Is there an equivalent frontend procedure? > > Simon === Subject: Transparent background with PNG how can I save an image to PNG format (eg. a simple plot), with the (white) background being transparent? I understand that PNG export supports alpha channel, but have no clue how to instruct Mathematica to exploit it. Istvan Zachar === Subject: Re: Shortest Path Problem Yes there is a big difference in Timing hanks for the tip. As for the unnecessary matrix, I decided to leave them just o better illustrate the problem, in the final optimized code, hopefully there will be only one. I will try to explain my problem to you and hope that you can help solve it. Is it possible to have a copy of your dissertation? The problem I have is a board game. The map in which the pieces move is made out of a grid of squares just like a chess board (with coordinates \x\ and \y\). You have the possibility of moving in 8 directions: up, down, left, right, and diagonals. But our pieces on this board has movement points that are deducted from the square that the \piece would move into\. The weights ranges from 1 to 6. As an example, Let us suppose that our piece is standing on a square of weight w1 and to the right there is a square o weight w2, if our piece moves to that square it would cost him w2 off his movement points, and if it goes back it would deduce w1. current problem as MyGrid. And how to efficiently translate this into a Graph, taking care of the limited arcs at the border and vertices of MyGrid is the task. After this is complete I would like to move my piece on the board, Wolfram enhanced, (hehehe) from an arbitrary point in the board (x1,y1) to (x2,y2) with the least movement cost for my piece. I hope I helped in making the problem clearer. Antonio > Many things can be done to optimize speed and memory. For instance, \ compa= re > > Timing[PossiblePositions = Tuples[Range[n], 2]; > NearestNeighbours = > Table[Intersection[{{i - 1, j - 1}, {i - 1, j}, {i - 1, j + 1}, {i= , > j - 1}, {i, j + 1}, {i + 1, j - 1}, {i + 1, j}, {i + 1, j = + 1}}, > PossiblePositions], {i, n}, {j, n}];] > > {0.786135, Null} > > with > > Timing[nearest = > DeleteCases[ > Table[{{i - 1, j - 1}, {i - 1, j}, {i - 1, j + 1}, {i, j - 1},= {i, > j + 1}, {i + 1, j - 1}, {i + 1, j}, {i + 1, j + 1}}, {= i, > n}, {j, n}], {0, _} | {_, 0} | {51, _} | {_, 51}, Infinity= ];] > > {0.033157, Null} > > nearest == NearestNeighbours > > True > > (Big difference in Timing, don't you think?) > > On the memory side of things, these matrices are probably unnecessary: = > NodesPosition, PossiblePositions, and WeightPositions. > > Too much of BuildWeightMatrix consists of infinite-weighted arcs: > > Count[BuildWeightMatrix, Infinity, {2}] > > 6230596 > > The major bottleneck you mentioned is in creating, then eliminating, \ thos= e > arcs... more than 6 million of them. > > If n=250, not 50, I suppose you'd have about THIS many: > > 50*50*% > > 15576490000 > t > MyGrid lists arcs, NOT nodes. > > If you really want to reach n=250, explain the problem to me. > > I solved MUCH larger shortest-path problems for my dissertation, more \ tha= n > 20 years ago... when computers were SLOW. > > Bobby > > > > > the code I used, > > > << Combinatorica` > > n = 50; > > (* Define my nxn Random Map *) > > MyGrid = Table[RandomInteger[{1, 6}], {i, 1, n}, {j, 1, n}]; > > (* Number of points on the map corrsponds to the number of nodes *) > > Nodes = Flatten[MyGrid]; > > NodesPosition = Range[Length[Nodes]]; > > PossiblePossitions = Tuples[Range[n], 2]; > > NearestNeighbours = > > Table[Intersection[{{i - 1, j - 1}, {i - 1, j}, {i - 1, j + 1}, {i, > > j - 1}, {i, j + 1}, {i + 1, j - 1}, {i + 1, j}, {i + 1, j += 1}}, > > PossiblePossitions], {i, n}, {j, n}]; > > WeightValues = > > Flatten[Apply[MyGrid[[#1, #2]] &, NearestNeighbours, {3}], 1]; > > WeightPositions = > > Flatten[Apply[n*(#1 - 1) + #2 &, NearestNeighbours, {3}], 1]; > > BuildWeightMatrix = > > Table[If[MemberQ[WeightPositions[[i]], j], > > WeightValues[[i, > > Position[WeightPositions[[i]], j][[1, 1]]]], \\[Infinity]], = {i, > > n^2}, {j, n^2}]; > > 1, n^2]; > > MatrixForm[MyGrid] > > (*MatrixForm[BuildWeightMatrix*) > > sp > > Print[\Movement cost is \, Total[Flatten[MyGrid][[Drop[sp, 1]]]]] > > MatrixPlot[MyGrid, > > Epilog -> {Thick, > > Line[{n - Mod[sp, n, 1] + 0.5, > > Quotient[sp - Mod[sp, n, 1], n] + 0.5}\\[Transpose]]}, > > ColorRules -> {1 -> Red, 2 -> Orange, 2 -> Yellow, 3 -> Green, > > 4 -> Blue, 5 -> Magenta, 6 -> Purple}] > > > Some of the code proposed crashed the kernel and in this one the > > bottle neck is in the IF conditional inside the table > > (BuildWeightMatrix) and the ShortestPath command. This here is for > > n=50, and actually I would like to solve something bigger like n=25= 0. > > So if you guys can make the code more efficient, please let me know. > > > Antonio > > >> > (up,down,left,right and the 4 diagonals) > > >> > So all directions are possible but they > >> > are asymetrical in the sense that they have diferent weights if g= oin= > > g > >> > foward or backward. > >> > All I know is that I have to use the Combinatorica package > > >> Hi. Here are some commands you may find helpful. > >> This is not complete because the diagonals are not complete. > >> I'm not sure what an efficient method for the diagonals would be just > >> yet. > >> I'm using Mathematica ver 7. > > >> Because the diagonals are not complete, I made it a simple graph by > >> removing the double path (combined path 2-3, and 3-2) > > >> This is just a 5 * 5 grid. > >> Hopefully, this will give you some ideas to work with. > > >> Needs[\Combinatorica`\] > > >> n = 5; > >> g = GridGraph[n, n]; > >> g = SetEdgeWeights[g, RandomInteger[{1, 5}, M[g]]]; > > >> diag = Table[ > >> s = (r - 1)*n + c; > >> {{s, s + n + 1}, {s, s + n - 1}, {s, s - n + 1}, {s, > >> s - n - 1}}, {r, 2, n - 1}, {c, 2, n - 1}]; > > >> diag = Flatten[diag, 2] // Sort; > > >> g = AddEdges[g, diag]; > > >> g = SetEdgeWeights[g, diag, RandomInteger[{1, 5}, Length[diag]]]; > > >> g = MakeSimple[g]; > > >> pth = Partition[ShortestPath[g, 1, n*n], 2, 1]; > > >> g = SetEdgeLabels[g, GetEdgeWeights[g]]; > > >> ShowGraph[ > >> Highlight[g, {pth}, > >> HighlightedEdgeColors -> Red], > >> VertexNumber -> True, > >> VertexNumberColor -> Blue] > > >> = = = > >> HTH > >> Dana DeLouis > > > > >> > I am not familiar with Graph theory and hope that some Mathematic= a > >> > users might help me. I am having a Shortest path problem that I h= ope > >> > to solve using Mathematica. > > >> > My input is a Grid defind as, > > >> > MyGrid = Table[RandomInteger[{1, 5}], {i, 1, 10}, {j, 1, 10}] > > >> > in this 10x10 grid i'd like the shortest path from point A, let's= sa= > > y > >> > MyGrid[[10, 10]] to point B MyGrid[[1, 1]]. For every point insid= e > >> > this square grid I have 8 possible directions or lines > >> > (up,down,left,right and the 4 diagonals). The weight of each step= is > >> > given inside the MyGrid cell, i.e. let MyGrid[[2, 3]]=1 and > >> MyGrid[[2, > >> > 4]]=3 > >> > So in going from coordinate (2,3) to (2,4) it takes 3 times as lo= ng = > > >> as > >> > if going from (2,4) to (2,3). So all directions are possible but = the= > > y > >> > are asymetrical in the sense that they have diferent weights if g= oin= > > g > >> > foward or backward. > > >> > I tried reading Mathematica help but it is very poor with no > >> examples. > >> > All I know is that I have to use the Combinatorica package and th= e > >> > ShortestPath[] command, but as a start I have no idea in how to > >> create > >> > a Graph needed as input to this command from MyGrid. > > > -- > DrMajor...@longhorns.com === Subject: Re: Shortest Path Problem Many things can be done to optimize speed and memory. For instance, compare Timing[PossiblePositions = Tuples[Range[n], 2]; NearestNeighbours = Table[Intersection[{{i - 1, j - 1}, {i - 1, j}, {i - 1, j + 1}, {i, j - 1}, {i, j + 1}, {i + 1, j - 1}, {i + 1, j}, {i + 1, j + 1}}, PossiblePositions], {i, n}, {j, n}];] {0.786135, Null} with Timing[nearest = DeleteCases[ Table[{{i - 1, j - 1}, {i - 1, j}, {i - 1, j + 1}, {i, j - 1}, {i, j + 1}, {i + 1, j - 1}, {i + 1, j}, {i + 1, j + 1}}, {i, n}, {j, n}], {0, _} | {_, 0} | {51, _} | {_, 51}, Infinity];] {0.033157, Null} nearest == NearestNeighbours True (Big difference in Timing, don't you think?) On the memory side of things, these matrices are probably unnecessary: NodesPosition, PossiblePositions, and WeightPositions. Too much of BuildWeightMatrix consists of infinite-weighted arcs: Count[BuildWeightMatrix, Infinity, {2}] 6230596 The major bottleneck you mentioned is in creating, then eliminating, those \ arcs... more than 6 million of them. If n=250, not 50, I suppose you'd have about THIS many: 50*50*% 15576490000 MyGrid lists arcs, NOT nodes. If you really want to reach n=250, explain the problem to me. I solved MUCH larger shortest-path problems for my dissertation, more than \ 20 years ago... when computers were SLOW. Bobby > the code I used, > > << Combinatorica` > n = 50; > (* Define my nxn Random Map *) > MyGrid = Table[RandomInteger[{1, 6}], {i, 1, n}, {j, 1, n}]; > (* Number of points on the map corrsponds to the number of nodes *) > Nodes = Flatten[MyGrid]; > NodesPosition = Range[Length[Nodes]]; > PossiblePossitions = Tuples[Range[n], 2]; > NearestNeighbours = > Table[Intersection[{{i - 1, j - 1}, {i - 1, j}, {i - 1, j + 1}, {i, > j - 1}, {i, j + 1}, {i + 1, j - 1}, {i + 1, j}, {i + 1, j + 1}}, > PossiblePossitions], {i, n}, {j, n}]; > WeightValues = > Flatten[Apply[MyGrid[[#1, #2]] &, NearestNeighbours, {3}], 1]; > WeightPositions = > Flatten[Apply[n*(#1 - 1) + #2 &, NearestNeighbours, {3}], 1]; > BuildWeightMatrix = > Table[If[MemberQ[WeightPositions[[i]], j], > WeightValues[[i, > Position[WeightPositions[[i]], j][[1, 1]]]], \\[Infinity]], {i, > n^2}, {j, n^2}]; > 1, n^2]; > MatrixForm[MyGrid] > (*MatrixForm[BuildWeightMatrix*) > sp > Print[\Movement cost is \, Total[Flatten[MyGrid][[Drop[sp, 1]]]]] > MatrixPlot[MyGrid, > Epilog -> {Thick, > Line[{n - Mod[sp, n, 1] + 0.5, > Quotient[sp - Mod[sp, n, 1], n] + 0.5}\\[Transpose]]}, > ColorRules -> {1 -> Red, 2 -> Orange, 2 -> Yellow, 3 -> Green, > 4 -> Blue, 5 -> Magenta, 6 -> Purple}] > > Some of the code proposed crashed the kernel and in this one the > bottle neck is in the IF conditional inside the table > (BuildWeightMatrix) and the ShortestPath command. This here is for > n=50, and actually I would like to solve something bigger like n=250. > So if you guys can make the code more efficient, please let me know. > > Antonio > > > > >> > (up,down,left,right and the 4 diagonals) >> >> > So all directions are possible but they >> > are asymetrical in the sense that they have diferent weights if goin= > g >> > foward or backward. >> > All I know is that I have to use the Combinatorica package >> >> Hi. Here are some commands you may find helpful. >> This is not complete because the diagonals are not complete. >> I'm not sure what an efficient method for the diagonals would be just >> yet. >> I'm using Mathematica ver 7. >> >> Because the diagonals are not complete, I made it a simple graph by >> removing the double path (combined path 2-3, and 3-2) >> >> This is just a 5 * 5 grid. >> Hopefully, this will give you some ideas to work with. >> >> Needs[\Combinatorica`\] >> >> n = 5; >> g = GridGraph[n, n]; >> g = SetEdgeWeights[g, RandomInteger[{1, 5}, M[g]]]; >> >> diag = Table[ >> s = (r - 1)*n + c; >> {{s, s + n + 1}, {s, s + n - 1}, {s, s - n + 1}, {s, >> s - n - 1}}, {r, 2, n - 1}, {c, 2, n - 1}]; >> >> diag = Flatten[diag, 2] // Sort; >> >> g = AddEdges[g, diag]; >> >> g = SetEdgeWeights[g, diag, RandomInteger[{1, 5}, Length[diag]]]; >> >> g = MakeSimple[g]; >> >> pth = Partition[ShortestPath[g, 1, n*n], 2, 1]; >> >> g = SetEdgeLabels[g, GetEdgeWeights[g]]; >> >> ShowGraph[ >> Highlight[g, {pth}, >> HighlightedEdgeColors -> Red], >> VertexNumber -> True, >> VertexNumberColor -> Blue] >> >> = = = >> HTH >> Dana DeLouis >> >> >> > >> > I am not familiar with Graph theory and hope that some Mathematica >> > users might help me. I am having a Shortest path problem that I hope >> > to solve using Mathematica. >> > >> > My input is a Grid defind as, >> > >> > MyGrid = Table[RandomInteger[{1, 5}], {i, 1, 10}, {j, 1, 10}] >> > >> > in this 10x10 grid i'd like the shortest path from point A, let's sa= > y >> > MyGrid[[10, 10]] to point B MyGrid[[1, 1]]. For every point inside >> > this square grid I have 8 possible directions or lines >> > (up,down,left,right and the 4 diagonals). The weight of each step is >> > given inside the MyGrid cell, i.e. let MyGrid[[2, 3]]=1 and >> MyGrid[[2, >> > 4]]=3 >> > So in going from coordinate (2,3) to (2,4) it takes 3 times as long = > >> as >> > if going from (2,4) to (2,3). So all directions are possible but the= > y >> > are asymetrical in the sense that they have diferent weights if goin= > g >> > foward or backward. >> > >> > I tried reading Mathematica help but it is very poor with no >> examples. >> > All I know is that I have to use the Combinatorica package and the >> > ShortestPath[] command, but as a start I have no idea in how to >> create >> > a Graph needed as input to this command from MyGrid. >> > >> > > > -- DrMajorBob@longhorns.com === Subject: Re: Shortest Path Problem the code I used, << Combinatorica` n = 50; (* Define my nxn Random Map *) MyGrid = Table[RandomInteger[{1, 6}], {i, 1, n}, {j, 1, n}]; (* Number of points on the map corrsponds to the number of nodes *) Nodes = Flatten[MyGrid]; NodesPosition = Range[Length[Nodes]]; PossiblePossitions = Tuples[Range[n], 2]; NearestNeighbours = Table[Intersection[{{i - 1, j - 1}, {i - 1, j}, {i - 1, j + 1}, {i, j - 1}, {i, j + 1}, {i + 1, j - 1}, {i + 1, j}, {i + 1, j + 1}}, PossiblePossitions], {i, n}, {j, n}]; WeightValues = Flatten[Apply[MyGrid[[#1, #2]] &, NearestNeighbours, {3}], 1]; WeightPositions = Flatten[Apply[n*(#1 - 1) + #2 &, NearestNeighbours, {3}], 1]; BuildWeightMatrix = Table[If[MemberQ[WeightPositions[[i]], j], WeightValues[[i, Position[WeightPositions[[i]], j][[1, 1]]]], \\[Infinity]], {i, n^2}, {j, n^2}]; 1, n^2]; MatrixForm[MyGrid] (*MatrixForm[BuildWeightMatrix*) sp Print[\Movement cost is \, Total[Flatten[MyGrid][[Drop[sp, 1]]]]] MatrixPlot[MyGrid, Epilog -> {Thick, Line[{n - Mod[sp, n, 1] + 0.5, Quotient[sp - Mod[sp, n, 1], n] + 0.5}\\[Transpose]]}, ColorRules -> {1 -> Red, 2 -> Orange, 2 -> Yellow, 3 -> Green, 4 -> Blue, 5 -> Magenta, 6 -> Purple}] Some of the code proposed crashed the kernel and in this one the bottle neck is in the IF conditional inside the table (BuildWeightMatrix) and the ShortestPath command. This here is for n=50, and actually I would like to solve something bigger like n=250. So if you guys can make the code more efficient, please let me know. Antonio > > (up,down,left,right and the 4 diagonals) > > > So all directions are possible but they > > are asymetrical in the sense that they have diferent weights if goin= g > > foward or backward. > > All I know is that I have to use the Combinatorica package > > Hi. Here are some commands you may find helpful. > This is not complete because the diagonals are not complete. > I'm not sure what an efficient method for the diagonals would be just > yet. > I'm using Mathematica ver 7. > > Because the diagonals are not complete, I made it a simple graph by > removing the double path (combined path 2-3, and 3-2) > > This is just a 5 * 5 grid. > Hopefully, this will give you some ideas to work with. > > Needs[\Combinatorica`\] > > n = 5; > g = GridGraph[n, n]; > g = SetEdgeWeights[g, RandomInteger[{1, 5}, M[g]]]; > > diag = Table[ > s = (r - 1)*n + c; > {{s, s + n + 1}, {s, s + n - 1}, {s, s - n + 1}, {s, > s - n - 1}}, {r, 2, n - 1}, {c, 2, n - 1}]; > > diag = Flatten[diag, 2] // Sort; > > g = AddEdges[g, diag]; > > g = SetEdgeWeights[g, diag, RandomInteger[{1, 5}, Length[diag]]]; > > g = MakeSimple[g]; > > pth = Partition[ShortestPath[g, 1, n*n], 2, 1]; > > g = SetEdgeLabels[g, GetEdgeWeights[g]]; > > ShowGraph[ > Highlight[g, {pth}, > HighlightedEdgeColors -> Red], > VertexNumber -> True, > VertexNumberColor -> Blue] > > = = = > HTH > Dana DeLouis > > > > > > I am not familiar with Graph theory and hope that some Mathematica > > users might help me. I am having a Shortest path problem that I hope > > to solve using Mathematica. > > > > My input is a Grid defind as, > > > > MyGrid = Table[RandomInteger[{1, 5}], {i, 1, 10}, {j, 1, 10}] > > > > in this 10x10 grid i'd like the shortest path from point A, let's sa= y > > MyGrid[[10, 10]] to point B MyGrid[[1, 1]]. For every point inside > > this square grid I have 8 possible directions or lines > > (up,down,left,right and the 4 diagonals). The weight of each step is > > given inside the MyGrid cell, i.e. let MyGrid[[2, 3]]=1 and > MyGrid[[2, > > 4]]=3 > > So in going from coordinate (2,3) to (2,4) it takes 3 times as long = > as > > if going from (2,4) to (2,3). So all directions are possible but the= y > > are asymetrical in the sense that they have diferent weights if goin= g > > foward or backward. > > > > I tried reading Mathematica help but it is very poor with no > examples. > > All I know is that I have to use the Combinatorica package and the > > ShortestPath[] command, but as a start I have no idea in how to > create > > a Graph needed as input to this command from MyGrid. > > > > === Subject: Re: Shortest Path Problem > My input is a Grid If I understand your question, here is one solution of many using Combinatorica. Note that there are many unit values on the grid, so the solution will be 'almost' a line from start to finish. I do not remember how to change the double arrows to a simple line, or perhaps just make the arrow heads smaller. I'm using Mathematica 7. Hopefully, if you want to go this route, this will give you some ideas. Needs[\Combinatorica`\] Note: A function that, if given from a to b, then make (a to b), and (b to a), and assign a weight of 1 in one direction, and a random value between 1 and 5 in the other direction. fx[{a_, b_}] := Module[{edgs, wts}, edgs = {{a, b}, {b, a}}; wts = RandomSample[{1, RandomInteger[{1, 5}]}]; g = SetEdgeWeights[g, edgs, wts]; ] n = 10; g = GridGraph[n, n] (* Note from output that it's a graph with 180 Edges, and 100 Vertices *) ShowGraph[g, VertexNumber -> True] grid = Edges[g] // Sort; Note: Make Diagonals d1 = Flatten[ Do[If[Mod[j, n, 1] != n, Sow[{j, j + n + 1}]], {j, 1, n*n - n - 1}] // Reap // Rest, 2]; d2 = Flatten[ Do[If[Mod[j, n, 1] != 1, Sow[{j, j + n - 1}]], {j, 2, n*n - n}] // Reap // Rest, 2]; diag = Union[d1, d2]; g = AddEdges[g, diag] (* now 342 Edges *) ShowGraph[g, VertexNumber -> True] g = MakeDirected[g] (* Doubled the edges to 684 *) ShowGraph[g, VertexNumber -> True] Map[fx, grid]; Map[fx, diag]; Note: ts is an abbreviation for Traveling-Salesman Path pth = Partition[ts = ShortestPath[g, 1, n*n], 2, 1]; ShowGraph[ Highlight[g, {pth}, HighlightedEdgeColors -> Red], VertexNumber -> True, VertexNumberColor -> Blue, EdgeStyle -> Thin, ImageSize -> 800] Here is the path: 1 to 12, then 12 to 22, etc... pth {{1, 12}, {12, 22}, {22, 23}, {23, 34}, {34, 45}, {45, 46}, {46, 56}, {56, 67}, {67, 78}, {78, 79}, {79, 90}, {90, 100}} Or used in the distance function... ts {1, 12, 22, 23, 34, 45, 46, 56, 67, 78, 79, 90, 100} Total Distance ... CostOfPath[g, ts] 13 Note: A listing of all edges and weights: Transpose[{Edges[g], GetEdgeWeights[g]}] // Sort // MatrixForm; An interesting change would be to make random values in both direction instead of one being the value '1 fx[{a_, b_}] := Module[{edgs, wts}, edgs = {{a, b}, {b, a}}; wts = {RandomInteger[{1, 5}], RandomInteger[{1, 5}]}; g = SetEdgeWeights[g, edgs, wts]; ] = = = = Anyway, Hope this helps... Dana DeLouis > > I am not familiar with Graph theory and hope that some Mathematica > users might help me. I am having a Shortest path problem that I hope > to solve using Mathematica. > > My input is a Grid defind as, > > MyGrid = Table[RandomInteger[{1, 5}], {i, 1, 10}, {j, 1, 10}] > > in this 10x10 grid i'd like the shortest path from point A, let's say > MyGrid[[10, 10]] to point B MyGrid[[1, 1]]. For every point inside > this square grid I have 8 possible directions or lines > (up,down,left,right and the 4 diagonals). The weight of each step is > given inside the MyGrid cell, i.e. let MyGrid[[2, 3]]=1 and MyGrid[[2, > 4]]=3 > So in going from coordinate (2,3) to (2,4) it takes 3 times as long as > if going from (2,4) to (2,3). So all directions are possible but they > are asymetrical in the sense that they have diferent weights if going > foward or backward. > > I tried reading Mathematica help but it is very poor with no examples. > All I know is that I have to use the Combinatorica package and the > ShortestPath[] command, but as a start I have no idea in how to create > a Graph needed as input to this command from MyGrid. > > === Subject: spatial finite differences in two dimensions (something like Is there a possibility in mathematica to get the coefficients or formula for approximation of spatial derivatives with finite differences. And, to get these formulas also for different orders of approximation? Specifically the function UFDWeights gives the coefficients for the 1D case, I need the same for the 2D case: partial derivatives: f_x, f_y, f_xy,f_xx,_fyy === Subject: Re: spatial finite differences in two dimensions (something like Sorry, in my previous message, I didn't see that you are interested in the 2D case. Mathematica gives the coefficient only for the 1D cases. Nevertheless the documentation explains how to contruct a 2D approximation with the coefficients of the 1D case. It gives a the example of the 2D Laplacian. gnm1pp$hht$1@smc.vnet.net... > > Is there a possibility in mathematica to get the coefficients or > formula for approximation of spatial derivatives with finite > differences. And, to get these formulas also for different orders of > approximation? > > Specifically the function UFDWeights gives the coefficients for the 1D > case, > > I need the same for the 2D case: partial derivatives: > > f_x, f_y, f_xy,f_xx,_fyy > > > > > === Subject: Re: spatial finite differences in two dimensions (something like yes, you can get theses coefficients. This is very well documented. On Mathematica version 7, look at the Help for NDSolve -->\Advanced Numerical Differential Equation Solving in mathematica\ ----> chapter \partial diferential equations\ -------> chapter \spatial derivative approximations\ ----------> especially : explanation about \NDSolve`FiniteDifferenceDerivative\ Exists also on Mathematica 5.1, in \Advanced documentation\ gnm1pp$hht$1@smc.vnet.net... > > Is there a possibility in mathematica to get the coefficients or > formula for approximation of spatial derivatives with finite > differences. And, to get these formulas also for different orders of > approximation? > > Specifically the function UFDWeights gives the coefficients for the 1D > case, > > I need the same for the 2D case: partial derivatives: > > f_x, f_y, f_xy,f_xx,_fyy > > > > > === Subject: Maximization problems consider a toy function 'func' of 6 parameters, and a set of constraints 'cons' for this function: In[45]:= func[b_, m_, s_, a_, n_, r_] := Total[{b, m, s, a, n, r}]; cons[b_, m_, s_, a_, n_, r_] := And[3 <= a <= 10, 1 <= n <= 10, 1 <= r <= n, 3 <= b <= 10, 1 <= m <= b, 1 <= s <= m, Binomial[b, m] <= a^n]; In[47]:= NMaximize[{func[b, m, s, a, n, r], And[cons[b, m, s, a, n, r]] }, {b, m, s, a, n, r}] Out[47]= {60., {b -> 10., m -> 10., s -> 10., a -> 10., n -> 10., r -> 10.}} In[48]:= Maximize[{func[b, m, s, a, n, r], And[cons[b, m, s, a, n, r]] }, {b, m, s, a, n, r}] Out[48]= Maximize[{a + b + m + n + r + s, 3 <= a <= 10 && 1 <= n <= 10 && 1 <= r <= n && 3 <= b <= 10 && 1 <= m <= b && 1 <= s <= m && Binomial[b, m] <= a^n}, {b, m, s, a, n, r}] While NMaximize gives the correct answer, Maximize is returned unevaluated. If I remove the last constraint from cons, then Maximize succeeds as well. Now why is it, that the symbolic method can't maximize the function? Any idea? Istvan Zachar === Subject: Expecting an image instead of image... how I love these error messages, so clear... I know it's more wysiwyg to copy&paste image icons on command lines, but I'm more used to do it the old way, also to remember where the image comes from... but I'm getting this funny message: a = Import[\k0004b.tif\] <> MorphologicalComponents[a] MorphologicalComponents::imginv: Expecting an image or graphics instead of Image[{{91,85... do you know what's happening here? alessandro === Subject: Latin Hypercube and other sampling algorithm but I could not find examples of Mathematica code for generating efficient multi-dimensional Monte Carlo simulations, like the Latin Hypercube sampling scheme. With Mathematica, as far as I understand, the difficulty may be to generate the samples successively, without handling all at once the huge set of samples which might be generated for more than a few variables. Not having found any explicit reference to this topic in the standard functions, I also tried to look at the NIntegrate sampling schemes (there are a several) to see if any of them could be used for the purpose, but I could not reach a conclusion. Does anybody have a code, e.g., for generating Latin Hypercube samples one at a time for N variables divided into M sampling intervals? ADL === Subject: Exporting data into a file, OpenWrite Frnds, Im getting an output tat is very big and i cant view that withitn the available screen. Im trying to write it into a file but i dont understand where it is. Will OpenWrite help?? I wnat the ans to be written to a notepad. is there any otehr way of exporting the data? Plz bear with me if my question is very silly, Im new to mathematica : ( Nandhini === Subject: Precise bitmaps A question was asked back in 2005 about precise bitmaps. I have a similar question with regard to Mathematica version 7. Looking at the new image-manipulation functions in V7, I expected this to be \ quick ... I'd like to be able to create a series of stimuli for use in an experiment. The first step in creating the stimuli is to create a 512 x 512 \ greyscale image with a white background and which contains the drawn objects. I tried the following to create a JPEG image with dimensions 128x128 ... circ=Graphics[Circle[{0,0},62]] rasterCirc=Rasterize[circ,RasterSize->{128,128}] Export[\circle.jpg\,rasterCirc] but instead the image dimensions are 360 x 363 pixels. I had also hoped that \ I could obtain an antialiased arc but the only antialiasing option seems to \ be for Style, which then produces a non-Graphics object. Can anyone see a simple (i.e., not very low-level programming) solution to the problem within Mathematica? What have I missed conceptually that would explain the 360x363 pixel dimensions instead of my expected 128x128? And is \ there a way to obtain the anti-aliased circle? Mark Diamond === Subject: Re: Precise bitmaps > A question was asked back in 2005 about precise bitmaps. I have a similar \ > question with regard to Mathematica version 7. > > Looking at the new image-manipulation functions in V7, I expected this to \ be > quick ... I'd like to be able to create a series of stimuli for use in an \ > experiment. The first step in creating the stimuli is to create a 512 x \ 512 > greyscale image with a white background and which contains the drawn > objects. > > I tried the following to create a JPEG image with dimensions 128x128 ... > > circ=Graphics[Circle[{0,0},62]] > rasterCirc=Rasterize[circ,RasterSize->{128,128}] > Export[\circle.jpg\,rasterCirc] > > but instead the image dimensions are 360 x 363 pixels. I had also hoped \ that > I could obtain an antialiased arc but the only antialiasing option seems \ to > be for Style, which then produces a non-Graphics object. > > Can anyone see a simple (i.e., not very low-level programming) solution to \ > the problem within Mathematica? What have I missed conceptually that would \ > explain the 360x363 pixel dimensions instead of my expected 128x128? And \ is > there a way to obtain the anti-aliased circle? > > > Mark Diamond > > > The problem is that circ is a graphics object of much lower resolution - you have to force it to be the size that you want to rasterize: circ = Graphics[Circle[{0, 0}, 62], ImageSize -> {512, 512}] rasterCirc = Rasterize[circ, RasterSize -> {512, 512}] Export[\circle.jpg\, rasterCirc] David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: Precise bitmaps > A question was asked back in 2005 about precise bitmaps. I have a similar > question with regard to Mathematica version 7. > > Looking at the new image-manipulation functions in V7, I expected this \ to= be > quick ... I'd like to be able to create a series of stimuli for use in an > experiment. The first step in creating the stimuli is to create a 512 x \ 5= 12 > greyscale image with a white background and which contains the drawn > objects. > > I tried the following to create a JPEG image with dimensions 128x128 ... > > circ=Graphics[Circle[{0,0},62]] > rasterCirc=Rasterize[circ,RasterSize->{128,128}] > Export[\circle.jpg\,rasterCirc] > > but instead the image dimensions are 360 x 363 pixels. I had also hoped \ t= hat > I could obtain an antialiased arc but the only antialiasing option seems \ = to > be for Style, which then produces a non-Graphics object. > > Can anyone see a simple (i.e., not very low-level programming) solution \ t= o > the problem within Mathematica? What have I missed conceptually that \ woul= d > explain the 360x363 pixel dimensions instead of my expected 128x128? And \ = is > there a way to obtain the anti-aliased circle? > > > Mark Diamond The solution for your problem is: circ = Graphics[Style[Circle[{0, 0}, 62], Antialiasing -> True], ImageSize -> {128, 128}] Export[\circle.jpg\, circ, \Smoothing\ -> 0, \CompressionLevel\ -> 0] The default \Automatic\ value of the option ImageSize results in producing raster graphics with 360 pixels width. This is undocumented behavior and I do not know how to change it: http://tinyurl.com/bl6jjg http://tinyurl.com/cwgbky === Subject: Re: Precise bitmaps > A question was asked back in 2005 about precise bitmaps. I have a similar > question with regard to Mathematica version 7. > > Looking at the new image-manipulation functions in V7, I expected this \ to= be > quick ... I'd like to be able to create a series of stimuli for use in an > experiment. The first step in creating the stimuli is to create a 512 x \ 5= 12 > greyscale image with a white background and which contains the drawn > objects. > > I tried the following to create a JPEG image with dimensions 128x128 ... > > circ=Graphics[Circle[{0,0},62]] > rasterCirc=Rasterize[circ,RasterSize->{128,128}] > Export[\circle.jpg\,rasterCirc] > > but instead the image dimensions are 360 x 363 pixels. I had also hoped \ t= hat > I could obtain an antialiased arc but the only antialiasing option seems \ = to > be for Style, which then produces a non-Graphics object. > > Can anyone see a simple (i.e., not very low-level programming) solution \ t= o > the problem within Mathematica? What have I missed conceptually that \ woul= d > explain the 360x363 pixel dimensions instead of my expected 128x128? And \ = is > there a way to obtain the anti-aliased circle? circ = Graphics[Circle[{0, 0}, 62], ImageSize -> 128] rasterCirc = Rasterize[circ] (* this step is not strictly necessary *) Export[\circle.jpg\,rasterCirc] -Rob === Subject: Re: Precise bitmaps circ = Graphics[Circle[{0, 0}, 62]]; img = Rasterize[circ, ImageSize -> {128, 128}]; and ImageDimensions[img] gives {128, 128} Jens > A question was asked back in 2005 about precise bitmaps. I have a similar \ > question with regard to Mathematica version 7. > > Looking at the new image-manipulation functions in V7, I expected this to \ be > quick ... I'd like to be able to create a series of stimuli for use in an \ > experiment. The first step in creating the stimuli is to create a 512 x \ 512 > greyscale image with a white background and which contains the drawn > objects. > > I tried the following to create a JPEG image with dimensions 128x128 ... > > circ=Graphics[Circle[{0,0},62]] > rasterCirc=Rasterize[circ,RasterSize->{128,128}] > Export[\circle.jpg\,rasterCirc] > > but instead the image dimensions are 360 x 363 pixels. I had also hoped \ that > I could obtain an antialiased arc but the only antialiasing option seems \ to > be for Style, which then produces a non-Graphics object. > > Can anyone see a simple (i.e., not very low-level programming) solution to \ > the problem within Mathematica? What have I missed conceptually that would \ > explain the 360x363 pixel dimensions instead of my expected 128x128? And \ is > there a way to obtain the anti-aliased circle? > > > Mark Diamond > > > === Subject: Re: Using VerticalSlider controls for Manipulate If you are going to use a Button, I would recommend that you assign some \ action to it (e.g., increment). a = 64; b = 64; Grid[{{VerticalSlider[Dynamic[a], {0, 127, 1}], VerticalSlider[Dynamic[b], {0, 127, 1}]}, {Button[Dynamic[a], a = Min[127, a + 1]], Button[Dynamic[b], b = Min[127, b + 1]]}}] Bob Hanlon I found a \solution\ which might interest others, so here is an example. As my intent is to allow dynamic values with labels for the sliders, the \Button\ approach is the next best thing :>) Dynamic[a]; Dynamic[b]; a = 64; b = 64; Print[ Column[ { Row[ {VerticalSlider[Dynamic[a], {0, 127, 1}], , \ \, VerticalSlider[Dynamic[b], {0, 127, 1}]} ], Row[{Dynamic[Button[a]], \ \, Dynamic[Button[b]]}] } ] ] P.S. Ideally I'd like to use Mathematica perhaps with the Orchestra-95 text based music language (for programming \ease\) to allow both MIDI [SoundNote[] based] AND additive synthesis [Play[] based] playback of music playable polyphonically with the Sound[] function whether for algorithmic music or not!. But it would be very helpful if Mathematica could IMPORT MIDI files and \ just export them (unless Version 7 can now -- v6 doesn't). Benjamin Tubb www.pdmusic.org > > > > > > > Benjamin, > > > you might have a look at the earlier thread,\Custom label for a slider > > in Manipulate\. > > > While I agree with David that Manipulate is not suitable for \ everything= , > > for those still wanting to use it there is Control[] in Version 7 that > > allows you to place Manipulate control statements flexibly, e.g. in > > grids, columns etc. > > > Yves > > > > > In reference to the Manipulate function, does anyone know how to use > > > row arranged variables with it, particular the VerticalSlider control > > > if possible. As it it the only placement alignment is either top, > > > bottom left or right but only in column formats, I want to use rows. > > > I'm using Mathematica v6.0.2. > > > > Benjamin Tubb > > >www.pdmusic.org-Hide quoted text - > > > - Show quoted text - > > from Stephen Wolfram already (but it expires 5 Mar 09), having only > bought ver 3 previously, and can't afford to upgrade (to $2500!) > otherwise. As it is I'm trying to develop some music Demonstration > Projects on as fast a learning curve as I can, despite having two hard > drive crashes last year, and only (finally) recovering late last > month, but at least I have DSL service now , and a new (mfg. 12/08) > 300GB hard drive! And I'm still using a WinXP Pro PC.- Hide quoted text - > > - Show quoted text - === Subject: Re: pde nonlinear modeling? > Does anyone know whether NonlinearModelFit can fit data to partial > differential equations? > > > > > There is an example of fitting a univariate pde defined using NDSolve in the Generalizations and Extensions section of the documentation for NonlinearModelFit at ref/NonlinearModelFit in the Documentation Center. The same type of approach could be used for a function defined via a pde. Darren Glosemeyer Wolfram Research === Subject: pde nonlinear modeling? Does anyone know whether NonlinearModelFit can fit data to partial differential equations? === Subject: Re: Dynamic Module with Trigger In your toy example, just add a second argument to the Dynamic[a] in the Slider... DynamicModule[{a = 3, b}, b = a; Column[{Slider[Dynamic[a, (a = #; b = a) &], {0, 10, 1}], Trigger[Dynamic[b, (b = #; b = b + a) &], {0, 25}], Row[{Dynamic[{a, b}]}], Graphics[{Dynamic[Line[{{0, 0}, {b, 0}}]]}, PlotRange -> {{0, 40}, {-10, 10}}, Frame -> True, ImageSize -> 72 6]}]] I also changed the b=2 initialization to instead be b=a. There are some things I would change about this example which would make \ the code considerably simpler and easier to understand, but I've decided not to since I don't know how inaccurately this example reflects real difficulties you're dealing with in your real-world problem. But, for example, I would \ have changed the first Dynamic to use (a=#, b=0)&, the Trigger Dynamic to use no special function at all, and the Graphics Dynamic to show a line with the computed point a+b. John Fultz jfultz@wolfram.com User Interface Group Wolfram Research, Inc. > In the toy DynamicModule below pressing the trigger makes an existing > line longer. The initial length of the line is controlled by a slider. > The module works but I want to add the feature that when I move the > slider the trigger resets itself and the now changed initial line is > drawn. Is it possible to do this? > > Hugh Goyder > > DynamicModule[ > {a = 3, b}, > b = 2; > Column[{ > Slider[Dynamic[a], {0, 10, 1}], > Trigger[Dynamic[b, (b = #; b = b + a) &], {0, 25}], > Row[{Dynamic[{a, b}]}], > Graphics[{Dynamic[Line[{{0, 0}, {b, 0}}]]}, > PlotRange -> {{0, 40}, {-10, 10}}, Frame -> True, > ImageSize -> 72 6] > }] > ] === Subject: What is \Depth of Atomic Objects\ ? The Mathematica Help in A.1.4 says \Atomic objects in Mathematica are considered to have depth 0 and yield True when tested with AtomQ.\ For example, numeric 4 is Integer and must be a Atomic object. Then I try the function Depth and AtomQ ; Depth[4] returns depth \1\. And AtomQ[4] returns \True\. Why can the function Depth return depth \0\ ? I wonder if meaning of the function \Depth\ differs from the word \depth\. But I feel somthing strange. How can I understand this ? === Subject: DiscretePlot I recently started the chapter on series in my Calculus II classes. I like to have my students make tables and plots of terms and partial sums of series, to help them develop some intuition about what it means for a series to converge or diverge, which leads naturally into convergence tests. (Give them something where it's hard to determine convergence/divergence from tables and plots, and the students will *ask* how can we know for sure.) Prior to Mathematica 7, we always had to start with a table, name it something, and use ListPlot to plot it. So now with Mathematica 7, I still have my students make some smallish tables (I like them to have numbers to look at it in addition to plots), but now we can plot directly with the new DiscretePlot. I like DiscretePlot a lot, except for one complaint I will get to below. As an example, consider the alternating harmonic series. My students know how to define a function for the terms and a function to generate the partial sums, then plot the terms or the partial sums with DiscretePlot, like so. a[n_] = (-1)^(n + 1)/n s[k_] := Sum[a[n], {n, 1, k}] DiscretePlot[s[k], {k, 1, 100},PlotLabel->\Partial sums\] We can turn off the filling. (I like the filling sometimes, but not \ always.) DiscretePlot[s[k], {k, 1, 100}, Filling -> None] All well and good. However, unlike ListPlot (which has Joined->False by default), DiscretePlot has Joined->Automatic by default. If we plot greater than 149 points with DiscretePlot, Mathematica joins the points, and it's a royal mess. DiscretePlot[s[k], {k, 1, 149}, Filling -> None] (* this is fine *) DiscretePlot[s[k], {k, 1, 150}, Filling -> None] (* this is a wreck *) As another example, try using DiscretePlot to plot terms of the sequence b(n)=sin(n). b[n_] = Sin[n]; DiscretePlot[b[n], {n, 0, 500}, Filling -> None] Well that's just hideous. Students just learning about sequences and series aren't going to have any idea what's going on. We can fix this behavior by setting Joined->False, like this: DiscretePlot[s[k], {k, 1, 150}, Filling -> None, Joined -> False] DiscretePlot[b[n], {n, 0, 500}, Filling -> None, Joined -> False] The students are having trouble remembering to do this, though, and I wonder why on earth Wolfram would design DiscretePlot this way. When I go to make a DiscretePlot, I do not *ever* expect -- or want -- the points to be joined. And why are the points not joined for < 150 points, and joined for >= 150 points? This seems completely arbitrary, and in fact I only discovered the 150 point cut-off by trial and error, and could find no explanation in the Documention as to what Joined->Automatic even does. I'd be far happier if DiscretePlot had Joined->False by default. -- Helen Read University of Vermont === Subject: Abstract Symbolic Matrix operations in Mathematica Can anybody tell me how to do operations on matrix equations without \ computing on the element level in Mathematica? In other words, for example, \ if I have two \abstract\ matrices A and B, what should I type to verify the \ following: (AT)^T = B^T A^T Would appreciate any thoughts. === Subject: Re: Exporting data into a file, OpenWrite >Frnds, Im getting an output tat is very big and i cant view that >withitn the available screen. Im trying to write it into a file but >i dont understand where it is. Will OpenWrite help?? I wnat the ans >to be written to a notepad. is there any otehr way of exporting the >data? OpenWrite is not likely to be what you want. This only opens a file so that something can be written to the file. In most cases, you will want to use Export. In addition to creating a finishes by closing the file. You indicated you want the \ans to be written to a notepad\. I take this to mean you want ASCII output that can be read by the Notepad application. If I have this correct, then Export[filename, data, \Table\] will do what you want. Here, data is a variable that contains the information to be written to the file. There are many possible formats to use with Export in addition to \Table\. Quite possibly, a different format would be better for your needs. So, it would probably be good for you to look at the documentation for Export using the Documentation Center. When you use Export, the file will be created in the current working directory. That is the directory that is returned by Directory[] Finally, you indicate your reason for writing the output to because the output is too large to be viewed on your screen. Mathematica offers a variety of ways to view output from calculations. Quite likely one or more of these might actually be more useful than writing the output out to a file and using some other application to view it. But without details of what output you are currently having difficulty with and what it is you are trying to do, I cannot offer specific suggestions. === Subject: Re: Exporting data into a file, OpenWrite > > When you use Export, the file will be created in the current > working directory. That is the directory that is returned by Directory[] > Bill, When you included this very sensible and helpful paragraph in the overall very helpful reply you gave to the OP on this thread, I suggest you also inadvertently touched on one of the, in my view, classic examples of Wolfram's inadequate approach to documentation for Mathematica. Export[] is a command which can be viewed as a kind of \shipping label\ or set of instructions for shipping data to somewhere, akin to the warehouse shipping labels one finds inside incoming amazon.com shipments, or the FedEx shipping labels I occasionally prepare online for outgoing shipments. As such the Export[] command specifically spells out what's to be shipped; what name (i.e., what product identification) is to be put on the package; and, in detail, how it's to be wrapped and packaged (i.e., the format). But after all this, the Export[] command itself says nothing -- gives no information at all -- about the equally crucial matter of _where_ this package is to be sent! And worse, if you go to the Help message for Export[] (up through v6, at least), and expand this message out to the fullest, it also gives _no_ information about this. If a slightly expanded version of your paragraph above had been included in the Export[] Help file, for example in the \More Information\ section, it would have told the OP where his data would be sent to (which you'll note was actually the key question in his opening sentence). But more than this, this simple addition to the Export[] documentation could gently help educate novice Export[] users to the concept of a \directory\ and of Directory[] type commands -- right at a time when they need this education, and are ready to absorb it. Is this less than optimum result for the Export[] help command just one particularly unfortunate example, that leaps out from the page? -- or a classic illustration of a general weakness in Wolfram's approach to user documentation? It's certainly the former -- my view is, it's also very much the latter. --AES === Subject: Multiple Computations Hello I can't figure out, how to compute multiple things in parallel with \ Mathematica. Say I have a computation A running (needing several hours to finish). How \ can I in parallel compute B (something much simpler), without having to wait \ for A to finish. === Subject: Mathematica problem Hello to everybody, i\\m desperatly trying to solve the following equation \ using mathematica but i can't can you propose me any solution??? The problem is: Use it to find the zero of f (x) = sin (2ì¥ x) \ \.89Ãâ 7x + 7 , stopping when the difference between two successive guesses is less than 0.1 (That is, 0 1 x \.89Ãâ x < 0.1) Run your program using \ initial guesses a) 0 x = 0 , b) 0 x =1, c) 0 x = 2 and d) 0 x = 3. We have to use the Newton-Raphson model. I know the model but i can't program it in mathematica. Could you please help me??? Maria === Subject: Re: Mathematica problem This group is not for solving your homework assignments. You should do it yourself otherwise you won't learn a thing. > Hello to everybody, i\\m desperatly trying to solve the following \ equation= using mathematica but i can't can you propose me any solution??? > > The problem is: > Use it to find the zero of f (x) = sin (2=CF=80 x) =E2=88=92 7x + 7 , s= topping > when the difference between two successive guesses is less than 0.1 (That > is, 0 1 x =E2=88=92 x < 0.1) Run your program using initial guesses a) 0 \ = x = 0 , b) > 0 x =1, c) 0 x = 2 and d) 0 x = 3. > We have to use the Newton-Raphson model. > I know the model but i can't program it in mathematica. > Could you please help me??? > > Maria === Subject: Mathematica question about commutativity of multiplication I have a 6x6 matrix in terms of 3 variables a,b,c. That is, each entry in the matrix is some polynomial in the variables a,b,c with integer coefficients. I wish to calculate the eigenvalues of this matrix, so if the matrix is called A, I type in Eigenvalues[A]. The problem is that the output is 500 pages long, so is not useful to me. I think part of the issue is that in my case, the variables a,b, and c commute. That is, ab = ba, ac = ca, and bc = cb. I really believe that if I could tell Mathematica that multiplication commutes with my variables, then the output would be simpler. My questions are : 1) How do I let Mathematica know that multiplication with my variables is commutative? 2) Also, when I typed Eigenvalues[A], the output had terms such as 2ab^2 #1^5. What is #1^5? Is this some sort of error? Did I make an error somewhere? The output also had the symbol &. Why is that there in the expression of an eigenvalue? 3) I understand that with 3 variables, the eigenvalues of a 6x6 matrix are difficult for Mathematica to compute, so it did take 15 seconds or so...is this part of my problem? James === Subject: Re: Mathematica question about commutativity of multiplication Hi James, I think that 1) and 3) are related. Mathematica by default assumes that variables commute (in fact it's hard to change this behaviour) . Your problem probably is that to get a times b, you need to enter a (space) b. With out the space, ab is a variable all by itself and different from ba. As for 2), the eigenvalues are found by solving the secular equation: Det[A-x 1]=0 for the eigenvalues x. This is a n'th order polynomial equation for matrices of size n. Thus you need the roots of high order polynomials. In general these can not be written in closed form, and so mathematica will output Root[] objects. The #1 refers to the variable of the pure function whose root is being found. I think that's enough to get you started... Simon === Subject: Re: Mathematica question about commutativity of multiplication > > I have a 6x6 matrix in terms of > 3 variables a,b,c. That is, each entry in the matrix > is some polynomial in the variables a,b,c > with integer coefficients. > > I wish to calculate the eigenvalues of this matrix, so > if the matrix is called A, I type in Eigenvalues[A]. > > The problem is that the output is 500 pages long, so is > not useful to me. I think part of the issue is that > in my case, the variables a,b, and c commute. That is, > ab = ba, ac = ca, and bc = cb. I really believe that > if I could tell Mathematica that multiplication commutes > with my variables, then the output would be simpler. If \a\ is a variable and \b\ is a variable, their product is \a*b\ or \a b\. \ab\ is just another variable unrelated to \a\ and \b\. Scott -- Scott Hemphill hemphill@alumni.caltech.edu \This isn't flying. This is falling, with style.\ -- Buzz Lightyear === Subject: Re: Mathematica question about commutativity of multiplication what had you expect, a 6 x 6 matrix have a 6. order characteristic polynomial. A closed form for 6. order polynomials does not exist and inserting all roots of the characteristic polynomial in to the matrix will make the expression not simpler. The question \I think part of the issue is that > in my case, the variables a,b, and c commute. \ is a bit unclear, Mathematica will always assume that a*b==b*a and the only way to have multiplication that does not commute is to use not Times[] but NonCommutativeMultiply[]. #1 is the short form of Slot[1] and #1^5 means the 5. power of Slot[1] as well as a^5 means the 5. power of a. And a^5 means a*a*a*a*a Jens > > I have a 6x6 matrix in terms of > 3 variables a,b,c. That is, each entry in the matrix > is some polynomial in the variables a,b,c > with integer coefficients. > > I wish to calculate the eigenvalues of this matrix, so > if the matrix is called A, I type in Eigenvalues[A]. > > The problem is that the output is 500 pages long, so is > not useful to me. I think part of the issue is that > in my case, the variables a,b, and c commute. That is, > ab = ba, ac = ca, and bc = cb. I really believe that > if I could tell Mathematica that multiplication commutes > with my variables, then the output would be simpler. > > My questions are : > > 1) How do I let Mathematica know that multiplication with > my variables is commutative? > 2) Also, when I typed Eigenvalues[A], the output had > terms such as 2ab^2 #1^5. What is #1^5? Is this some > sort of error? Did I make an error somewhere? The > output also had the symbol &. Why is that there in > the expression of an eigenvalue? > 3) I understand that with 3 variables, the eigenvalues > of a 6x6 matrix are difficult for Mathematica to compute, > so it did take 15 seconds or so...is this part of > my problem? > > > James > === Subject: question related to (-1)^(1/3) I have tried expression: RecurrenceTable[{x[n + 1] == -x[n]^(1/3), x[0] == 1}, x, {n, 1, 200}] // N Mathematica produce {-1., -0.5 - 0.866025 I, -0.766044 + 0.642788 I, -0.686242 - 0.727374 I, -0.71393 + 0.700217 I, -0.704818 - 0.709389 I, ... But it should be {1, -1, 1, -1, ... } If you try (-1)^(1/3) In[10]:= (-1)^(1/3) Out[10]= (-1)^(1/3) In[11]:= % // N Out[11]= 0.5 + 0.866025 I === Subject: FullGraphics of Graphics3D is there a method to convert e.g. a Plot3D result to such a Graphics3D object, \in which objects specified by graphics options are given as explicit lists of graphics primitives\ (taken from FullGraphics). It seems so that FullGraphics was deliberately created to handle 2D graphics, but not 3D, although the same functionality (represent axes, ticks, etc. by explicit primitives) would be useful in 3D as well: axes, labels, ticks, frames etc. as primitives in 3D environment. Istvan Zachar === Subject: Symbolic matrix operations Does anyone know how to perform symbolic matrix operations in mathematica without computing on the element level? For example, if I need to expand (AB)^T and get the result in the form B^T A^T, what should I type? I am trying to find a way to simplify matrix equations without actually multiplying, transposing, inversing etc matrices on the element level. DS === Subject: Re: Symbolic matrix operations Hi DS, As far as I know, Mathematica does not have any native support for noncommutative algebras (such as matrices). When I've had to deal with such things, I construct a new multiplication (based on, say CenterDot) and give Mathematica the relevant rules. If you only want to work with relatively simple expressions this is probably (powerful and quick) enough... A group at UCSD has developed a package, but I've never played with it.... (now put that on my to do list!) http://math.ucsd.edu/~ncalg/ OR \ http://library.wolfram.com/infocenter/MathSource/4594/ It seems to have everything you want (but is a bit old...) The appendix of this thesis \ http://theses.library.uwa.edu.au/adt-WU2007.0179/ also has some noncommutative algebra using Mathematica... Simon === Subject: Re: Symbolic matrix operations Symbolic matrices and operations on them are not built-in in Mathematica, but it is possible to define them. Look into the GeneralVectorAnalysis package at \ http://ftp.physics.uwa.edu.au/pub/Mathematica/Calculus/ for ideas of an implementation. > Does anyone know how to perform symbolic matrix operations in mathematica > without computing on the element level? > For example, if I need to expand (AB)^T and get the result in the form \ B^= T > A^T, what should I type? > I am trying to find a way to simplify matrix equations without actually > multiplying, transposing, inversing etc matrices on the element level. > > DS === Subject: follow up on pde nonlinear modeling Sorry to bug the forum again - this is a follow-up to my other question, about fitting data points to a nonlinear partial differential equation. It turns out that it works, but it's very slow. Unfortunately, Mathematica returns all 240000 pieces of data I'm using every time I call them in a variable. When I open up my notebook to try to find my results, my computer crashes from displaying so many numbers at once. Does anyone have any suggestions as to how I could speed things up? I know I'm not saturating my memory, so this has to be a cpu bottleneck. Is there any way I could get \ the Mathematica gui to speed up, like maybe distributing it across multiple cores or something? === Subject: Re: follow up on pde nonlinear modeling Hi Ned, You write: \Unfortunately, Mathematica returns all 240000 pieces of data I'm using every time I call them in a variable.\ I'm a bit puzzled by this remark. You are calling them in a variable? It's possible to call a function, but to call a variable? Do you mean you assign them to a variable? In that case, a simple semicolon at the end of the assignment statement will surpress printing of the assigned data. As of version 6, Mathematica catches large output and shows only part of it. Are you using an earlier version? Furthermore you write: \ When I open up my notebook to try to find my results, my computer crashes from displaying so many numbers at once.\ Again, this is a puzzling statement. It suggests that you have this 240000 pieces of data right there in this notebook. Can't you use Import or the lower level Read/ReadList functions and read from an external data file? Also, your results are not automatically saved in your notebook. So, opening the notebook looking for results won't usually do you much good unless you have saved the notebook after the calculation. But then, I don't think that a file that can be saved can't be opened. Come to think about it: are you fitting a pde to these 240000 pieces of data? Isn't that a little bit overspecified? > Sorry to bug the forum again - this is a follow-up to my other question, > about fitting data points to a nonlinear partial differential equation. \ I= t > turns out that it works, but it's very slow. Unfortunately, Mathematica > returns all 240000 pieces of data I'm using every time I call them in a > variable. When I open up my notebook to try to find my results, my \ comput= er > crashes from displaying so many numbers at once. Does anyone have any > suggestions as to how I could speed things up? I know I'm not saturating \ = my > memory, so this has to be a cpu bottleneck. Is there any way I could get \ = the > Mathematica gui to speed up, like maybe distributing it across multiple > cores or something? > === Subject: no message from Minimize[] on a weird function(x^x) !?! Hello MathGroup: I have: f[x_]=x^x Plot[f[x],{x,-3,3.}] What makes this a weird function is that when x<0, the function is discontinuous and non-differentiable and has a global minimum at -1. To answer the question: \what is the minimum of this function\, I tried FindMinimum[f[x],{x,2}] (* this appears correct *) > {0.692201, {x -> 0.367879}} FindMinimum[f[x],{x,2}] (* this complains about the gradient, but appears correct *) > FindMinimum::nrgnum: The gradient is not a vector of real numbers at {x} = \ {-1.}. >> > {-1., {x -> -1.}} NMinimize[f[x], x] (* this gives the minimum in the positive domain *) > {0.692201, {x -> 0.367879}} Minimize[f[x], x] (* this gives no answer and no error message *) > Minimize[x^x, x] Is this expected behavior? TIA. Roger Williams Franklin Laboratory === Subject: Re: no message from Minimize[] on a weird function(x^x) !?! Hi Roger If you tell Mathematica that x needs to be positive, all is well. In[1]:= Minimize[x^x, x] Out[1]= Minimize[x^x, x] In[2]:= Minimize[{x^x, x > 0}, x] Out[2]= {E^(-1/E), {x -> 1/E}} In[3]:= FindMinimum[x^x, x] Out[3]= {0.692201, {x -> 0.367879}} In[4]:= N[%2] Out[4]= {0.692201, {x -> 0.367879}} In the help ref/Minimize it says \Possible Issues: Minimize requires that all functions present in the input be real-valued:\ Simon === Subject: Re: please is it possible with mathematica, thank you! > Hi mathematica community! > I have this input: Not[(y > 0)] and Exists[{x}, (x > 0) && y == x - > 1] > I want mathematica to give me y==0 as output. > Is it possible and if it is what predefined function should I use?In > this function I want to make this assumption: > x and y are integers. > thank you very much. > You have to add he condition that y is an integer, otherwise your conclusion does not follow. There are various of ways of doing this Reduce[!y > 0 && Element[y, Integers] && Exists[x, x > 0 && y == x - 1]] y == 0 Andrzej Kozlowski === Subject: Re: question related to (-1)^(1/3) No, because (-1)^(1/3) is NOT -1. Rather, it is the principal cube-root of -1. > I have tried expression: > RecurrenceTable[{x[n + 1] == -x[n]^(1/3), x[0] == 1}, > x, {n, 1, 200}] // N > > Mathematica produce > {-1., -0.5 - 0.866025 I, -0.766044 + 0.642788 I, -0.686242 - > 0.727374 I, -0.71393 + 0.700217 I, -0.704818 - 0.709389 I, > ... > > But it should be {1, -1, 1, -1, ... } > > If you try (-1)^(1/3) > > In[10]:= (-1)^(1/3) > > Out[10]= (-1)^(1/3) > > In[11]:= % // N > > Out[11]= 0.5 + 0.866025 I > > > -- 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: ListVectorPlot3D with VectorPoints->All On Dec 30 2008, 2:51 am, \Sjoerd C. de Vries\ > Hi all, > > I was playing with ListVectorPlot3D, which plots a vector field based > on a list of position and vector pairs. According to the documentation > it interpolates unless you include a VectorPoints -> All option. So > why then does > > ListVectorPlot3D[ Table[{{x, y, z}, {x, y, z}}, {x, -1, 1, .1}, {y, > -1, 1, .1}, {z, -1, 1, .1}], VectorPoints -> All] > > not work? > > BTW: Although the ListVectorPlot3D doc page lists VectorPoints -> All > as a valid setting it does not occur in the VectorPoints doc page > itself. > > I can confirm this for the form ListVectorPlot3D[{{{x1,x2,x3}, {v1,v2,v3}}, ...}] in Mathematica 7 on Mac OS X. To force plotting of \ vectors only at the prescribed points {x1,x2,x3}, the option VectorPoints->All given in the documentation doesn't work. But fortunately one can achieve the desired result with something like this: With[{grid = Tuples[{Range[10], Range[10], zRange = Range[2]}]}, ListVectorPlot3D[Map[{#, Cross[#, {0, 0, 1}]} &, grid], VectorPoints -> grid]] The problem is that when I change zRange to zRange = Range[1] (corresponding to points all in a single plane), ListVectorPlot gives an error message saying that my data grid \... is not a valid vector field data set or a valid list of data sets.\ My guess is that this happens because ListVectorPlot still tries to do an interpolation even though I've told it exactly where to put the vectors. This is a bug, I would say, because there is no reason at all to do any interpolation if VectorPoints is set to a specific point list. Jens === Subject: Re: no message from Minimize[] on a weird function(x^x) f[x_] := x^x Minimize[f[x], x] Minimize[x^x,x] Minimize returns unevaluated because it is trying to provide a symbolic \ result and cannot solve the problem. You need to simplify the problem by \ providing the appropriate constraint. Minimize[{f[x], x > 0}, x] {E^(-E^(-1)), {x -> 1/E}} % // N {0.692201,{x->0.367879}} As with Minimize, MinValue and ArgMin also need the constraint {MinValue[f[x], x], ArgMin[f[x], x]} {MinValue[x^x,x],ArgMin[x^x,x]} {MinValue[{f[x], x > 0}, x], ArgMin[{f[x], x > 0}, x]} {E^(-E^(-1)), 1/E} Numerical techniques do not need the constraint presumably because their \ search starts with x > 0 FindMinimum[f[x], x] {0.692201,{x->0.367879}} FindArgMin[f[x], x] {0.367879} FindMinValue[f[x], x] 0.692201 NMinimize[f[x], x] {0.692201,{x->0.367879}} NMinValue[f[x], x] 0.692201 Bob Hanlon Hello MathGroup: I have: f[x_]=x^x Plot[f[x],{x,-3,3.}] What makes this a weird function is that when x<0, the function is discontinuous and non-differentiable and has a global minimum at -1. To answer the question: \what is the minimum of this function\, I tried FindMinimum[f[x],{x,2}] (* this appears correct *) > {0.692201, {x -> 0.367879}} FindMinimum[f[x],{x,2}] (* this complains about the gradient, but appears correct *) > FindMinimum::nrgnum: The gradient is not a vector of real numbers at {x} = \ {-1.}. >> > {-1., {x -> -1.}} NMinimize[f[x], x] (* this gives the minimum in the positive domain *) > {0.692201, {x -> 0.367879}} Minimize[f[x], x] (* this gives no answer and no error message *) > Minimize[x^x, x] Is this expected behavior? TIA. Roger Williams Franklin Laboratory === Subject: Re: Could someone run this on Mathematica 7.0? > Aaron, > with > > In[8]:= $Version > Out[8]= \7.0 for Mac OS X x86 (64-bit) (November 11, 2008)\ > > I get > > 32.66443126862095 > > > Adriano Pascoletti > > 2009/2/22 Aaron Fude > >> >> I'm not sure if such a request is appropiate on this newsgroup, but I >> know that Mathematica changed some aspects of Hypergeometric functions >> from version 6 to version 7. I have version 6 and I want to make sure >> that an error that I am looking for is due to Mathematica. The code is >> (thank you!) >> >> C0[x_][theta_] := Cos[Pi x]/Cos[theta] - 1 >> C1[x_] := C0[x]' >> C2[x_] := C1[x]' >> >> psi[r_] := BesselJ[0, BesselJZero[0, 1]* r]/( >> Sqrt[Pi] BesselJ[1, BesselJZero[0, 1]]) >> >> L[x_][r_, theta_] := >> 1/(1 + C0[x][ >> theta])^2 ((1 + C1[x][theta]^2/(1 + C0[x][theta])^2)*(psi''[r] + >> 1/r psi'[r]) >> - (C2[x][theta] (1 + C0[x][theta]) - >> C1[x][theta]^2)/(1 + C0[x][theta])^2*1/r psi'[r]) >> >> s = L[x][r, x*alpha] // Series[#, {x, 0, 2}] &; >> >> -Integrate[psi[r]*s*r, {alpha, -Pi, Pi}, {r, 0, 1}] + >> Pi*psi[0]^2 + (1/3 Pi^3)*psi[0]^2 x^2 // Coefficient[#, x, 2] & // >> N >> >> >> > === Subject: Re: Could someone run this on Mathematica 7.0? Aaron, with In[8]:= $Version Out[8]= \7.0 for Mac OS X x86 (64-bit) (November 11, 2008)\ I get 32.66443126862095 Adriano Pascoletti 2009/2/22 Aaron Fude > > I'm not sure if such a request is appropiate on this newsgroup, but I > know that Mathematica changed some aspects of Hypergeometric functions > from version 6 to version 7. I have version 6 and I want to make sure > that an error that I am looking for is due to Mathematica. The code is > (thank you!) > > C0[x_][theta_] := Cos[Pi x]/Cos[theta] - 1 > C1[x_] := C0[x]' > C2[x_] := C1[x]' > > psi[r_] := BesselJ[0, BesselJZero[0, 1]* r]/( > Sqrt[Pi] BesselJ[1, BesselJZero[0, 1]]) > > L[x_][r_, theta_] := > 1/(1 + C0[x][ > theta])^2 ((1 + C1[x][theta]^2/(1 + C0[x][theta])^2)*(psi''[r] + > 1/r psi'[r]) > - (C2[x][theta] (1 + C0[x][theta]) - > C1[x][theta]^2)/(1 + C0[x][theta])^2*1/r psi'[r]) > > s = L[x][r, x*alpha] // Series[#, {x, 0, 2}] &; > > -Integrate[psi[r]*s*r, {alpha, -Pi, Pi}, {r, 0, 1}] + > Pi*psi[0]^2 + (1/3 Pi^3)*psi[0]^2 x^2 // Coefficient[#, x, 2] & // > N > > === Subject: Could someone run this on Mathematica 7.0? I'm not sure if such a request is appropiate on this newsgroup, but I know that Mathematica changed some aspects of Hypergeometric functions from version 6 to version 7. I have version 6 and I want to make sure that an error that I am looking for is due to Mathematica. The code is (thank you!) C0[x_][theta_] := Cos[Pi x]/Cos[theta] - 1 C1[x_] := C0[x]' C2[x_] := C1[x]' psi[r_] := BesselJ[0, BesselJZero[0, 1]* r]/( Sqrt[Pi] BesselJ[1, BesselJZero[0, 1]]) L[x_][r_, theta_] := 1/(1 + C0[x][ theta])^2 ((1 + C1[x][theta]^2/(1 + C0[x][theta])^2)*(psi''[r] + 1/r psi'[r]) - (C2[x][theta] (1 + C0[x][theta]) - C1[x][theta]^2)/(1 + C0[x][theta])^2*1/r psi'[r]) s = L[x][r, x*alpha] // Series[#, {x, 0, 2}] &; -Integrate[psi[r]*s*r, {alpha, -Pi, Pi}, {r, 0, 1}] + Pi*psi[0]^2 + (1/3 Pi^3)*psi[0]^2 x^2 // Coefficient[#, x, 2] & // N === Subject: Re: question related to (-1)^(1/3) This misunderstanding pops up over and over again in this group. Please type tutorial/FunctionsThatDoNotHaveUniqueValues in the search bar of the mathematica doc centre. On Feb 22, 7:33 am, \=D2=BB=D2=B6=D6=AA=C7=EF\ \ = > I have tried expression: > RecurrenceTable[{x[n + 1] == -x[n]^(1/3), x[0] == 1}, > x, {n, 1, 200}] // N > > Mathematica produce > {-1., -0.5 - 0.866025 I, -0.766044 + 0.642788 I, -0.686242 - > 0.727374 I, -0.71393 + 0.700217 I, -0.704818 - 0.709389 I, > ... > > But it should be {1, -1, 1, -1, ... } > > If you try (-1)^(1/3) > > In[10]:= (-1)^(1/3) > > Out[10]= (-1)^(1/3) > > In[11]:= % // N > > Out[11]= 0.5 + 0.866025 I === Subject: Re: question related to (-1)^(1/3) >I have tried expression: RecurrenceTable[{x[n + 1] == -x[n]^(1/3), >x[0] == 1}, >x, {n, 1, 200}] // N >Mathematica produce >{-1., -0.5 - 0.866025 I, -0.766044 + 0.642788 I, -0.686242 - >0.727374 I, -0.71393 + 0.700217 I, -0.704818 - 0.709389 I, >... >But it should be {1, -1, 1, -1, ... } By default, Mathematica does not restrict solutions to real numbers. Specifically, In[21]:= NSolve[x^3 == -1, x] Out[21]= {{x->-1.},{x->0.5-0.866025 I},{x->0.5+0.866025 I}} and In[23]:= RSolve[{x[n + 1] == -x[n]^(1/3), x[0] == 1}, x[n], n] Out[23]= {{x[n] -> E^((-(1/2))*I*Pi*3^(1 - n)*(1 - 3^n))}, {x[n] -> E^(-((1/2)*I*Pi*3^(1 - n)*(1 - 3^n)) - (2*I*Pi)/3^n)}, {x[n] -> E^((2*I*Pi)/3^n - (1/2)*I*Pi*3^(1 - n)* (1 - 3^n))}} Consequently, the list retuned by RecurrenceTable also includes complex values. === Subject: Re: Optimization problem Those functions seem to work great. I am analyzing high speed video which luckily is easily parallizable but it still took quite a bit of Adam > Adam, > >>> am >>> having an optimization problem. What I am basically trying to do is >>> convert an image to HSB color space and then test each pixel to >>> see if >>> the H,S,B values fall within a certain range, making it a 1 if >>> it's in >>> the specified range else a 0. Notice I have multiplied the raw HSV >>> values to have ranges of [0,369], [0,100],[0,100] respectively. I >>> however get an order of magnitude difference between running two >>> operations that I can't rectify. >>> >>> Notice the image I am using to that I call \frame\ is available for >>> download at \ http://www.physics.uc.edu/~simpson/page11/files/OptimizationProblem.jpg >>> : >>> >>> //test each pixel to see if the value of Hue,Saturation,Brightness >>> fall within a certain range and make the value 1 if it is, else a 0: >>> Image[Map[ >>> If[320 <= 359 #[[1]] <= 355 && 65 <= 100 #[[2]] <= 80 && >>> 30 <= 100 #[[3]] <= 75, 1, 0] &, >>> ImageData[frame], {2}]] // AbsoluteTiming >>> >>> 0.282983 Seconds >>> >>> If however I create a function as such ,even after compiling it >>> which >>> helped slightly, that is equal to the above If statement I get an >>> order of magnitude higher time. >>> >>> Hmin=320; >>> Hmax=359; >>> Smin=65; >>> Smax=80; >>> Bmin=30; >>> Bmax=75; >>> >>> PixelMatch = Compile[{{H, _Real}, {S, _Real}, {B, _Real}}, >>> If[(Hmin <= H*359 <= Hmax) &&(Smin <= S*100 <= Smax) && >>> (Bmin <= B*100 <= Bmax), 1, 0]] >>> >>> Image[Map[PixelMatch[#[[1]], #[[2]], #[[3]]] &, >>> ImageData[frame], {2}]] // AbsoluteTiming >>> >>> 2.012571 Seconds >>> >>> Any help is highly appreciated. >>> >>> Adam Simpson > > Map automatically tries to compile the function you specify. > > With your first approach, I would recommend using Binarize or > ImageApply > for the job, as they could get optimized in further versions: > > With[{hmin = 320/359., hmax = 355/359., smin = .65, smax = .8, > bmin = .3, bmax = .75}, > Binarize[frame, > hmin <= #[[1]] <= hmax && smin <= #[[2]] <= smax && > bmin <= #[[3]] <= bmax &]] // AbsoluteTiming > > 0.212292 s. > > A much faster approach is to process the whole 2d arrays at one go > using > functions which can operate on them directly: > > With[{hmin = 320/359., hmax = 355/359., smin = .65, smax = .8, > bmin = .3, bmax = .75}, > Image[Unitize[ > Times @@ > MapThread[ > Clip[#1, #2, {0, 0}] &, {ImageData[frame, > Interleaving -> False], {{hmin, hmax}, {smin, smax}, {bmin, > bmax}}}]], \Bit\]] // AbsoluteTiming > > 0.088738 s. > > > Matthias Odisio > Wolfram Research > > > > === Subject: Re: Optimization problem much the same times as the slower original function. ~2 seconds compared to ~.2 seconds when the If statement is directly inside of Map[]. >> having an optimization problem. What I am basically trying to do is >> convert an image to HSB color space and then test each pixel to see >> if >> the H,S,B values fall within a certain range, making it a 1 if it's >> in >> the specified range else a 0. Notice I have multiplied the raw HSV >> values to have ranges of [0,369], [0,100],[0,100] respectively. I >> however get an order of magnitude difference between running two >> operations that I can't rectify. >> >> Notice the image I am using to that I call \frame\ is available for >> download at \ http://www.physics.uc.edu/~simpson/page11/files/OptimizationProblem.jpg >> : >> >> //test each pixel to see if the value of Hue,Saturation,Brightness >> fall within a certain range and make the value 1 if it is, else a 0: >> Image[Map[ >> If[320 <= 359 #[[1]] <= 355 && 65 <= 100 #[[2]] <= 80 && >> 30 <= 100 #[[3]] <= 75, 1, 0] &, >> ImageData[frame], {2}]] // AbsoluteTiming >> >> 0.282983 Seconds >> >> If however I create a function as such ,even after compiling it which >> helped slightly, that is equal to the above If statement I get an >> order of magnitude higher time. >> >> Hmin=320; >> Hmax=359; >> Smin=65; >> Smax=80; >> Bmin=30; >> Bmax=75; >> >> PixelMatch = Compile[{{H, _Real}, {S, _Real}, {B, _Real}}, >> If[(Hmin <= H*359 <= Hmax) &&(Smin <= S*100 <= Smax) && >> (Bmin <= B*100 <= Bmax), 1, 0]] >> >> Image[Map[PixelMatch[#[[1]], #[[2]], #[[3]]] &, >> ImageData[frame], {2}]] // AbsoluteTiming >> >> 2.012571 Seconds >> >> Any help is highly appreciated. >> >> Adam Simpson > > It's a scoping issue, more or less, having to do with Compile having > HoldAll attribute. If you check your PixelMatch[[4]] you will see it > is > actually making several function calls. > > This can be rectified using either approach below. The first forces an > evaluation of teh body of the Compile. The second makes the values > visible to everything inside the With[], including the body of that > Compile. > > PixelMatch2 = Compile[{{H, _Real}, {S, _Real}, {B, _Real}}, > Evaluate[If[(Hmin <= H*359 <= Hmax) &&(Smin <= S*100 <= Smax) && > (Bmin <= B*100 <= Bmax), 1, 0]]] > > PixelMatch3 = With[ > {Hmin=320, Hmax=359, Smin=65, Smax=80, Bmin=30, Bmax=75}, > Compile[{{H, _Real}, {S, _Real}, {B, _Real}}, > If[(Hmin <= H*359 <= Hmax) &&(Smin <= S*100 <= Smax) && > (Bmin <= B*100 <= Bmax), 1, 0]]] > > Daniel Lichtblau > Wolfram Research > > > > === Subject: Re: Optimization problem Adam, >> having an optimization problem. What I am basically trying to do is >> convert an image to HSB color space and then test each pixel to see if >> the H,S,B values fall within a certain range, making it a 1 if it's in >> the specified range else a 0. Notice I have multiplied the raw HSV >> values to have ranges of [0,369], [0,100],[0,100] respectively. I >> however get an order of magnitude difference between running two >> operations that I can't rectify. >> >> Notice the image I am using to that I call \frame\ is available for >> download at \ http://www.physics.uc.edu/~simpson/page11/files/OptimizationProblem.jpg >> : >> >> //test each pixel to see if the value of Hue,Saturation,Brightness >> fall within a certain range and make the value 1 if it is, else a 0: >> Image[Map[ >> If[320 <= 359 #[[1]] <= 355 && 65 <= 100 #[[2]] <= 80 && >> 30 <= 100 #[[3]] <= 75, 1, 0] &, >> ImageData[frame], {2}]] // AbsoluteTiming >> >> 0.282983 Seconds >> >> If however I create a function as such ,even after compiling it which >> helped slightly, that is equal to the above If statement I get an >> order of magnitude higher time. >> >> Hmin=320; >> Hmax=359; >> Smin=65; >> Smax=80; >> Bmin=30; >> Bmax=75; >> >> PixelMatch = Compile[{{H, _Real}, {S, _Real}, {B, _Real}}, >> If[(Hmin <= H*359 <= Hmax) &&(Smin <= S*100 <= Smax) && >> (Bmin <= B*100 <= Bmax), 1, 0]] >> >> Image[Map[PixelMatch[#[[1]], #[[2]], #[[3]]] &, >> ImageData[frame], {2}]] // AbsoluteTiming >> >> 2.012571 Seconds >> >> Any help is highly appreciated. >> >> Adam Simpson Map automatically tries to compile the function you specify. With your first approach, I would recommend using Binarize or ImageApply for the job, as they could get optimized in further versions: With[{hmin = 320/359., hmax = 355/359., smin = .65, smax = .8, bmin = .3, bmax = .75}, Binarize[frame, hmin <= #[[1]] <= hmax && smin <= #[[2]] <= smax && bmin <= #[[3]] <= bmax &]] // AbsoluteTiming 0.212292 s. A much faster approach is to process the whole 2d arrays at one go using functions which can operate on them directly: With[{hmin = 320/359., hmax = 355/359., smin = .65, smax = .8, bmin = .3, bmax = .75}, Image[Unitize[ Times @@ MapThread[ Clip[#1, #2, {0, 0}] &, {ImageData[frame, Interleaving -> False], {{hmin, hmax}, {smin, smax}, {bmin, bmax}}}]], \Bit\]] // AbsoluteTiming 0.088738 s. Matthias Odisio Wolfram Research === Subject: Re: Optimization problem > having an optimization problem. What I am basically trying to do is > convert an image to HSB color space and then test each pixel to see if > the H,S,B values fall within a certain range, making it a 1 if it's in > the specified range else a 0. Notice I have multiplied the raw HSV > values to have ranges of [0,369], [0,100],[0,100] respectively. I > however get an order of magnitude difference between running two > operations that I can't rectify. > > Notice the image I am using to that I call \frame\ is available for > download at \ http://www.physics.uc.edu/~simpson/page11/files/OptimizationProblem.jpg > : > > //test each pixel to see if the value of Hue,Saturation,Brightness > fall within a certain range and make the value 1 if it is, else a 0: > Image[Map[ > If[320 <= 359 #[[1]] <= 355 && 65 <= 100 #[[2]] <= 80 && > 30 <= 100 #[[3]] <= 75, 1, 0] &, > ImageData[frame], {2}]] // AbsoluteTiming > > 0.282983 Seconds > > If however I create a function as such ,even after compiling it which > helped slightly, that is equal to the above If statement I get an > order of magnitude higher time. > > Hmin=320; > Hmax=359; > Smin=65; > Smax=80; > Bmin=30; > Bmax=75; > > PixelMatch = Compile[{{H, _Real}, {S, _Real}, {B, _Real}}, > If[(Hmin <= H*359 <= Hmax) &&(Smin <= S*100 <= Smax) && > (Bmin <= B*100 <= Bmax), 1, 0]] > > Image[Map[PixelMatch[#[[1]], #[[2]], #[[3]]] &, > ImageData[frame], {2}]] // AbsoluteTiming > > 2.012571 Seconds > > Any help is highly appreciated. > > Adam Simpson It's a scoping issue, more or less, having to do with Compile having HoldAll attribute. If you check your PixelMatch[[4]] you will see it is actually making several function calls. This can be rectified using either approach below. The first forces an evaluation of teh body of the Compile. The second makes the values visible to everything inside the With[], including the body of that \ Compile. PixelMatch2 = Compile[{{H, _Real}, {S, _Real}, {B, _Real}}, Evaluate[If[(Hmin <= H*359 <= Hmax) &&(Smin <= S*100 <= Smax) && (Bmin <= B*100 <= Bmax), 1, 0]]] PixelMatch3 = With[ {Hmin=320, Hmax=359, Smin=65, Smax=80, Bmin=30, Bmax=75}, Compile[{{H, _Real}, {S, _Real}, {B, _Real}}, If[(Hmin <= H*359 <= Hmax) &&(Smin <= S*100 <= Smax) && (Bmin <= B*100 <= Bmax), 1, 0]]] Daniel Lichtblau Wolfram Research === Subject: Optimization problem having an optimization problem. What I am basically trying to do is convert an image to HSB color space and then test each pixel to see if the H,S,B values fall within a certain range, making it a 1 if it's in the specified range else a 0. Notice I have multiplied the raw HSV values to have ranges of [0,369], [0,100],[0,100] respectively. I however get an order of magnitude difference between running two operations that I can't rectify. Notice the image I am using to that I call \frame\ is available for download at \ http://www.physics.uc.edu/~simpson/page11/files/OptimizationProblem.jpg : //test each pixel to see if the value of Hue,Saturation,Brightness fall within a certain range and make the value 1 if it is, else a 0: Image[Map[ If[320 <= 359 #[[1]] <= 355 && 65 <= 100 #[[2]] <= 80 && 30 <= 100 #[[3]] <= 75, 1, 0] &, ImageData[frame], {2}]] // AbsoluteTiming 0.282983 Seconds If however I create a function as such ,even after compiling it which helped slightly, that is equal to the above If statement I get an order of magnitude higher time. Hmin=320; Hmax=359; Smin=65; Smax=80; Bmin=30; Bmax=75; PixelMatch = Compile[{{H, _Real}, {S, _Real}, {B, _Real}}, If[(Hmin <= H*359 <= Hmax) &&(Smin <= S*100 <= Smax) && (Bmin <= B*100 <= Bmax), 1, 0]] Image[Map[PixelMatch[#[[1]], #[[2]], #[[3]]] &, ImageData[frame], {2}]] // AbsoluteTiming 2.012571 Seconds Any help is highly appreciated. Adam Simpson === Subject: Re: question related to (-1)^(1/3) (-1)^(1/3) == Exp[I*Pi/3] True Exp[I*Pi/3] // N 0.5+0.866025 I Exp[I*Pi/3]^3 -1 Sign[-1]*Abs[-1]^(1/3) -1 RecurrenceTable[{x[n + 1] == -Sign[x[n]]*Abs[x[n]]^(1/3), x[0] == 1}, x, {n, 1, 10}] {-1,1,-1,1,-1,1,-1,1,-1,1} Bob Hanlon ---- \=C3=92=C2=BB=C3=92=C2=B6=C3=96=C2=AA=C3=87=C3=AF\ \ Mathematica are considered to have depth 0 and yield True when >tested with AtomQ.\ For example, numeric 4 is Integer and must be a >Atomic object. Then I try the function Depth and AtomQ ; Depth[4] >returns depth \1\. And AtomQ[4] returns \True\. Why can the function >Depth return depth \0\ ? I wonder if meaning of the function \Depth\ >differs from the word \depth\. But I feel somthing strange. How can >I understand this ? There seems to be an inconsistency in the documentation. The documentation for Depth under more information states: Raw objects have depth 1. That would seem to preclude any object in Mathematica from having depth 0. It would seem the only way to remove the inconsistency would be to say raw objects are different than atomic objects. But the documentation for AtomQ under more information states: AtomQ gives True for symbols, numbers, strings and other raw objects, such as sparse arrays. and AtomQ gives True for any object whose subparts cannot be accessed using functions like Map. Checking: In[10]:= s = SparseArray[{{1, 1} -> 1, {2, 2} -> 2, {3, 3} -> 3, {1, 3} -> 4}] Out[10]= SparseArray[<4>,{3,3}] In[11]:= AtomQ[s] Out[11]= True But, In[12]:=Depth[s] Out[12]=3 In[13]:=Total /@ s Out[13]={5, 2, 3} which seems to contradict the documentation noted above. === Subject: Error using Manpulate that is NOT obvious (to me) Using Mathematica 6.0.2, I can't get this relatively straight forward code \ to work, Can anyone explain what's wrong and how to fix it. It's essentially intended to be musician utility for using the SoundNote function which I hope to further elaborate by also converting any (MIDI note range frequency) into the appropriate MIDI note number and pitch bend values assumming a fine tuning RPN range of +/- 1 semitone, allowing 100 cents \sensitivity\ to be defined. Manipulate[ DynamicModule[{f, m, s, sd, pt, p, o}, f = N[(440/64) 2^((m + 3)/12)]; sd = {\C\, \C#\, \D\, \D#\, \E\, \F\, \F#\, \G\, \G#\, \A\, \A#\, \B\}; s = m - 60; pt = Mod[m, 12]; p = sd[[pt + 1]]; o = Integer[m/12] - 1; Print[ \MIDI Note Number (0-127)\, m, \ equals \, f, \ Hertz (8-12600)\, \, and its SoundNote number (-60 to 67) is \, s, \, which has the Pitch name of (C to B) \, p, \ in Octave (-1 to 9) \, o, \.\ ] ], {m, 0, 127, 1}, SaveDefinitions -> True ] Benjamin Tubb using Mathematica 6.0.2 and still occasionally v3.0.1 === Subject: Re: most ChemicalData molecule plots missing? [solved] > i'm getting a lot of missing molecule plots for even the simplest and > most common molecules in ChemicalData[]... > > most hydrocarbons are also missing. > > is this normal, or could there be something wrong with my mathematica > install or a cached curated data problem? > > i was expecting molecule plots to be automatically generated from the > chemical formulas, but looks like it's not. i guess its down to > manually using graphics3d, spheres, and cylinders ... > automatically generate the molecule plot based on ElementData[atom, \AtomicRadius\] ElementData[atom, \Abbreviation\] ChemicalData[chem, \AtomPositions\] ChemicalData[chem, \VertexCoordinates\] ChemicalData[chem, \VertexTypes\] ChemicalData[chem, \EdgeRules\] my code uses VertexCoordinates if AtomPositions is missing, but does not handle both missing. another potential improvement would be to have double/triple edge rules where applicable (all bonds are drawn as a single tube in my code). cheers, Mitch ------------------------- ElementPlot3D[atom_, {x_: 0, y_: 0}] := Module[{radius}, radius = ElementData[atom, \AtomicRadius\]; {ElementData[atom, \IconColor\], Sphere[{x, y, 0}, .4 radius], Black, Style[Text[ElementData[atom, \Abbreviation\], {x, y, .4 radius}], FontSize -> 12]} ] ElementPlot3D[atom_, {x_: 0, y_: 0, z_: 0}] := Module[{radius}, radius = ElementData[atom, \AtomicRadius\]; {Darker@ElementData[atom, \IconColor\], Sphere[{x, y, z}, .5 \ radius]} ] MoleculePlot3D[chem_, opts : OptionsPattern[{ImageSize -> 200, Frame -> True}]] := Module[ {atomCoordinates, atomTypes, atomColors, atomGraphics, edgeRules, edgeGraphics}, atomCoordinates = ChemicalData[chem, \AtomPositions\] /. _Missing -> ChemicalData[chem, \VertexCoordinates\]; atomTypes = ChemicalData[chem, \VertexTypes\]; edgeRules = ChemicalData[chem, \EdgeRules\]; edgeGraphics = Table[Tube[{ If[Length@First@atomCoordinates > 2, atomCoordinates[[edgeRules[[i, 1]]]], Append[atomCoordinates[[edgeRules[[i, 1]]]], 0]], If[Length@First@atomCoordinates > 2, atomCoordinates[[edgeRules[[i, 2]]]], Append[atomCoordinates[[edgeRules[[i, 2]]]], 0]] }, 4, VertexColors -> Evaluate[ ElementData[#, \IconColor\] & /@ atomTypes[[{edgeRules[[i, 1]], edgeRules[[i, 2]]}]]]], {i, Length@edgeRules}]; atomGraphics = Table[ElementPlot3D[atomTypes[[i]], atomCoordinates[[i]]], {i, Length@atomCoordinates}]; Graphics3D[{Thick, edgeGraphics, atomGraphics}, Boxed -> False, ViewPoint -> Top, Background -> GrayLevel@.9, ImagePadding -> 20, ImageSize -> \ {400, 280}, Lighting -> \Neutral\] ] GraphicsRow[{MoleculePlot3D@\CarbonDioxide\, MoleculePlot3D@\Ethanol\}, ImageSize -> 500] === Subject: Re: Exporting data into a file, OpenWrite > When you use Export, the file will be created in the current > working directory. I might add \...unless you include the full path to the file in the filename (using double slashes to separate directories and files, as a slash is used as an escape character in strings)\ === Subject: Re: Expecting an image instead of image... This is probably because you were working in the documentation centre. It seems that the doc text contains separate environments (indicated by dotted lines) which don't share variable values. The variable a that you assigned is in one part and the MorphologicalComponents[a] part in the other. If I try it like this I get a similar error message. On Feb 20, 12:45 pm, \alexxx.ma...@gmail.com\ > how I love these error messages, so clear... > > I know it's more wysiwyg to copy&paste image icons on command lines, > but I'm more used to do it the old way, also to remember where the > image comes from... > but I'm getting this funny message: > > a = Import[\k0004b.tif\] > <> > > MorphologicalComponents[a] > MorphologicalComponents::imginv: > Expecting an image or graphics instead of Image[{{91,85... > > do you know what's happening here? > > alessandro === Subject: Re: Symbolic matrix operations Hi there, My \Exterior Differential Calculus and Symbolic Matrix Algebra\ package (http://www.inp.demokritos.gr/~sbonano/EDC/), allows the user to define arbitrary symbols (like A, B) that will be treated as matrices. The package \ uses the symbol \[Wedge]\ for matrix multiplication, and contains \ definitions for symbolic application of Transpose, trace and the Cayley-Hamilton theorem \ (see examples in EDC_Manual.nb and in matrixEDCexamples.nb). Good luck! S. Bonanos > > Does anyone know how to perform symbolic matrix operations in > mathematica > without computing on the element level? > For example, if I need to expand (AB)^T and get the result in the form > B^T > A^T, what should I type? > I am trying to find a way to simplify matrix equations without actually > multiplying, transposing, inversing etc matrices on the element level. > > DS > > === Subject: newbie: can't Manipulate ListPlot of recurrence summary: I'm trying to Manipulate the logistic map. I can ListPlot it, but when I try to Manipulate, the UI behaves weirdly. details: === As advertised by the Subject:, I'm new to Mathematica (specifically 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any lapses in terminology. I'd also appreciate pointers to specific docs rather than just an RTFM. I'm trying to model the logistic map y=a y (1-y): http://en.wikipedia.org/wiki/Logistic_map http://mathworld.wolfram.com/LogisticMap.html http://www.phy.duke.edu/~palmer/notebooks/LogisticMap.nb To start with I just tried to plot it, which works: Clear[a, y]; a=3.5; y=0.4; ListPlot[Table[y=a y (1-y),{50}],Joined->True] I'd like to Manipulate a and y, but when I try to Clear[a, y]; Manipulate[ ListPlot[Table[y=a y (1-y),{50}],Joined->True], {{a, 3.5}, 0, 4}, {{y, 0.4}, 0, 1}] I get weird behavior: 1 initially the y slider oscillates 2 initially the plot displays but flashes (apparently between two phases) until I click one of the sliders 3 the y slider will not move 4 the a slider can be dragged, but to no effect (i.e. the plot does not change) 5 there are no error messages What am I doing wrong? and how can I Manipulate this map? TIA, Tom Roche === Subject: newbie: programmatic sequence of plots? How to get a programmatic sequence of plots? === As advertised by the Subject:, I'm new to Mathematica (specifically 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any lapses in terminology. I'd also appreciate pointers to specific docs rather than just an RTFM. Since I'm currently unable to model the logistic map y=a y (1-y) (see previous post) I'm trying to do a series of plots of it, to see how behavior changes over time. I can get a plot of a single instance with Clear[a,y,y0,nRecurr]; a=3.5; y0=0.4; nRecurr=50; ListPlot[ RecurrenceTable[{y[n+1]==a y[n] (1-y[n]),y[0]==y0}, y,{n,1,nRecurr}],Joined->True ] I can get a sequence of tables of values with Clear[a, y, y0, nRecurr, yinit, yinc, yfinal]; a = 3.5; nRecurr = 50; yinit = 0.1; yinc = 0.01; yfinal = 0.2; For[y0 = yinit, y0 <= yfinal, y0 += yinc, Print[y0, \:\\n\, RecurrenceTable[{y[n + 1] == a y[n] (1 - y[n]), y[0] == y0}, y, {n, 1, nRecurr}]]] But when I try to plot those values with Clear[a, y, y0, nRecurr, yinit, yinc, yfinal]; a = 3.5; nRecurr = 50; yinit = 0.1; yinc = 0.01; yfinal = 0.2; For[y0 = yinit, y0 <= yfinal, y0 += yinc, ListPlot[ RecurrenceTable[ {y[n + 1] == a y[n] (1 - y[n]), y[0] == y0}, y, {n, 1, nRecurr} ] ,Joined->True] ] I get absolutely nothing: no plot, no error message, no nada. Similarly, when I try to plot the difference between two runs of the map with seqDiff[a_,y_,inc_]:=Module[ {r=y,s=y+inc}, ListPlot[ Table[r=a r (1-r),{50}]-Table[s=a s (1-s),{50}], Joined->True,PlotRange->{-1,1} ] ] seqDiff[4.0,0.3,0.1] I get a plot. But when I try to put that inside a for loop Clear[a, i,init,inc,final]; a = 4.0; init=0.3; inc=0.1; final=0.5; For[i=init,i<=final,i+=inc,seqDiff[a,i,inc]] I get nothing: no plot, no error message. What am I doing wrong? How to get a series of plots? TIA, Tom Roche === Subject: Re: Exporting data into a file, OpenWrite >>When you use Export, the file will be created in the current >>working directory. That is the directory that is returned by >>Directory[] >If a slightly expanded version of your paragraph above had been >included in the Export[] Help file, for example in the \More >Information\ section, it would have told the OP where his data would >be sent to (which you'll note was actually the key question in his >opening sentence). >But more than this, this simple addition to the Export[] >documentation could gently help educate novice Export[] users to the >concept of a \directory\ and of Directory[] type commands -- right >at a time when they need this education, and are ready to absorb it. >Is this less than optimum result for the Export[] help command just >one particularly unfortunate example, that leaps out from the page? >-- or a classic illustration of a general weakness in Wolfram's >approach to user documentation? It's certainly the former -- my >view is, it's also very much the latter. There are several trades to be made when documenting anything as complex as Mathematica. True, it would not be difficult to add details of where files are created in the documentation for Export. But doing *just* that leads to an inconsistency in the documentation since the same information is applicable to any operation that creates files. That inconsistency can be removed by adding the same information to *all* commands it is pertinent to. Now once you do this consider the impact on maintaining the documentation in a consistent state. Changes to where files are kept now need to be made in several places instead of just one. As a consequence, more effort is needed to maintain the documentation and there is far more opportunity for error. This argues strongly for not repeating the same information in multiple places. There is no right/wrong answer as to where to document details of where files are created. No matter how Wolfram documents this information, there will always be someone to argue it should have been done differently. === Subject: Re: Abstract Symbolic Matrix operations in Mathematica as far as I know, mma considers a matrix as a bunch of elements. Those may be symbolic, but not the matrix itself. This leaves two avenues to proceed. You may either setup a matrix with explicit dimensions and symbolic elements (using e.g. Array). Or you may define a new data type, where you have to specify the rules yourself. E.g, assuming we call a symbolic matrix with name x: SymMat[x]. The rules: Unprotect[Transpose]; Transpose[a_SymMat. b_SymMat] := Transpose[b].Transpose[a] Transpose[a_SymMat + b_SymMat] := Transpose[a] + Transpose[b] etc. Here I changed the definition of Transpose for simplicity. However, if you are not sure what you are doing, it would be better to define a new operator (e.g. myTranspose). Then,f you the say: Transpose[SymMat[x].SymMat[y]] you will get: Transpose[SymMat[y]].Transpose[SymMat[x]] hope this helps, Daniel > Can anybody tell me how to do operations on matrix equations without \ computing on the element level in Mathematica? In other words, for example, \ if I have two \abstract\ matrices A and B, what should I type to verify the \ following: > > (AT)^T = B^T A^T > > Would appreciate any thoughts. > === Subject: Re: Abstract Symbolic Matrix operations in Mathematica > Can anybody tell me how to do operations on matrix equations without \ computing on the element level in Mathematica? In other words, for example, \ if I have two \abstract\ matrices A and B, what should I type to verify the \ following: > > (AT)^T = B^T A^T > > Would appreciate any thoughts. > Basically, you are trying to do noncommutative algebra in Mathematica. The first thing is to choose a notation for multiplication that will not get re-ordered automatically. ** or \\[CircleTimes] are the usual choices. After this, you have to provide some rules to specify how to expand an operation like transpose. E.g. ncExpand[trans[a_ ** b_]]:=ncExpand[trans[b]]**ncExpand[trans[a]]; ncExpand[a_]:=a; (note that this will recursively expand transposes of more than 2 matrices) The details can become messy however, because you may want a notation for ordinary scalars, etc. It may be worth it if you want to manipulate complicated expressions of this sort. David Bailey http://www.dbaileyconsultancy.co.uk === Subject: Re: question related to (-1)^(1/3) I just want to get the real solution of (-1)^(1/3). BTW, I have read the tutorial but I am still confused with its explanation. But that is not important, I just feel it is inconvenient for the following problem: RecurrenceTable[{x[n + 1] == -x[n]^(1/3), x[0] == 1}, x, {n, 1, 200}] // N I consider there should be a way to limit the output in the domain real. for example, in MAXIMA (%i1) domain; (%o1) real (%i2) (-1)^(1/3); (%o2) -1 (%i3) domain:complex; (%o3) complex (%i4) (-1)^(1/3),numer; (%o4) 0.86602540378444*%i+0.5 > This misunderstanding pops up over and over again in this group. > Please type tutorial/FunctionsThatDoNotHaveUniqueValues in the search > bar of the mathematica doc centre. > > > On Feb 22, 7:33 am, \=D2=BB=D2=B6=D6=AA=C7=EF\ \ = > > I have tried expression: > > RecurrenceTable[{x[n + 1] == -x[n]^(1/3), x[0] == 1}, > > x, {n, 1, 200}] // N > > > > Mathematica produce > > {-1., -0.5 - 0.866025 I, -0.766044 + 0.642788 I, -0.686242 - > > 0.727374 I, -0.71393 + 0.700217 I, -0.704818 - 0.709389 I, > > ... > > > > But it should be {1, -1, 1, -1, ... } > > > > If you try (-1)^(1/3) > > > > In[10]:= (-1)^(1/3) > > > > Out[10]= (-1)^(1/3) > > > > In[11]:= % // N > > > > Out[11]= 0.5 + 0.866025 I > > > === Subject: Re: question related to (-1)^(1/3) I just want to get the real solution of (-1)^(1/3). BTW, I have read the tutorial but I am still confused with its explanation. But that is not important, I just feel it is inconvenient for the following problem: RecurrenceTable[{x[n + 1] == -x[n]^(1/3), x[0] == 1}, x, {n, 1, 200}] // N I consider there should be a way to limit the output in the domain real. for example, in MAXIMA (%i1) domain; (%o1) real (%i2) (-1)^(1/3); (%o2) -1 (%i3) domain:complex; (%o3) complex (%i4) (-1)^(1/3),numer; (%o4) 0.86602540378444*%i+0.5 > This misunderstanding pops up over and over again in this group. > Please type tutorial/FunctionsThatDoNotHaveUniqueValues in the search > bar of the mathematica doc centre. > === Subject: newbie: how to define, typeset a multi-rule function? === As advertised by the Subject:, I'm new to Mathematica (specifically 7.0.0 for Students for 32-bit Windows on XP Pro) so please excuse any lapses in terminology. I'd also appreciate pointers to specific docs rather than just an RTFM. I suspect in this case I just need to know what the appropriate term is for what I'm trying to create. However I've tried searching the docs for various permutation