A48 == Does anyone know whether there exists an implementation of the> numerical methods for the SDE like in the book by Kloeden & Platen> Numerical Solution of Stochastic Differential Equations in> Mathematica?See http://math.ucsd.edu/~williams/courses/math286.html and http://www.warwick.ac.uk/statsdept/staff/WSK/ ca.htmlPaulReply-To: kuska@informatik.uni-leipzig.de ==== Hi,Needs[Miscellaneous` RealOnly`]Plot[x^(2/3), {x, -1, 0}]works as you expect. Jens> I have a simple (supposedly) question...> I used the following command to draw a plot, but Mathematica could not run> properly.> Plot[x^(2/3),{x,-1,0}]> I know the problem is about calculating (-1)^(1/3) in mathematica. Although> (-1)^(1/3) = -1,> mathematica tries to calculate it numerically and gives complex results> 0.5+0.8i> How to solve this problem and restrict the solution to be only real numbers?> ==== Use:Needs[Miscellaneous'RealOnly']Plot[x^(2/3) , {x,-1,0}]This will work.-- Nilton> I have a simple (supposedly) question...> I used the following command to draw a plot, but Mathematica could not run> properly.> Plot[x^(2/3),{x,-1,0}]> I know the problem is about calculating (-1)^(1/3) in mathematica. Although> (-1)^(1/3) = -1,> mathematica tries to calculate it numerically and gives complex results> 0.5+0.8i> How to solve this problem and restrict the solution to be only real numbers?> ==== In[1]:=< I know the problem is about calculating (-1)^(1/3) in mathematica.Although> (-1)^(1/3) = -1,> mathematica tries to calculate it numerically and gives complex results> 0.5+0.8i> How to solve this problem and restrict the solution to be only realnumbers?>Reply-To: drbob@bigfoot.com ==== Do you want the third root of x squared, or the square of the third root of x?Here are the third roots of -1, the square of each, and finally that result to the reciprocal power:{#, Conjugate@#, # # #} &@Exp[I 2 Pi/3] // ComplexExpand%^2 // ComplexExpand%^(3/2) // ComplexExpand{-(1/2) + (I*Sqrt[3])/2, -(1/2) - (I*Sqrt[3])/2, 1}{-(1/2) - (I*Sqrt[3])/2, -(1/2) + (I*Sqrt[3])/2, 1}{ -1, -1, 1}The real root doesn't get us back to -1, as we would probably like. In other words, (x^(2/3))^(3/2) is not x, if we insist on real roots.If we take the other approach, squaring and then taking the third root, and then raising to the 3/2 power, we get the same answers. (Take the real third root and then multiply by the three third roots of 1.)((-1)^2)^(1/3){1, Exp[I 2Pi/3], Exp[I 4Pi/3]} // ComplexExpand%^(3/2) // ComplexExpand{1, -(1/2) + (I*Sqrt[3])/2, -(1/2) - (I*Sqrt[3])/2}{1, -1, -1}Again, the real 2/3 power of x is positive, and raising it to the 3/2 power doesn't give x. Obviously, the real 2/3 power isn't always the one you want, then!Still, if you want to graph it, ask for it specifically:Plot[(x^2)^(1/3), {x, -1, 0}]BobbyOn Wed, 12 Feb 2003 03:52:57 -0500 (EST), Ye Hu I have a simple (supposedly) question... I used the following command to draw a plot, but Mathematica could not > run> properly. Plot[x^(2/3),{x,-1,0}]> I know the problem is about calculating (-1)^(1/3) in mathematica. > Although> (-1)^(1/3) = -1,> mathematica tries to calculate it numerically and gives complex results> 0.5+0.8i> How to solve this problem and restrict the solution to be only real > numbers?>-- majort@cox-internet.comBobby R. Treat ==== > What's the best way (simple, general and without dummy functions) to define> in mathematica 4.2 a differential operator? For example, how can I evaluate laplacian operator in spherical coordinates> ? (without using ad-hoc packages...What do you mean by ad-hoc packages...?> i want to enter expression of d/dx, d/dy, d/dz and mathematica must> compute (d/dx)^2+(d/dy)^2+(d/dz)^2)At http://physics.uwa.edu.au/pub/Mathematica/MathGroup/ ChangingVariables.nbyou'll find one approach.For a more general and powerful approach there is the Differential Formspackage by Frank Zizza at http://www.willamette.edu/~zizza/ and theSymbolic Vector Analysis package by Hong Qin at http://w3.pppl.gov/~hongqin/computerAlgebra.htm> How can i evaluate powers,product etc... of operators ?topic. See also The Mathematica Journal 8(1).Paul~~~ ==== Hi math groupListDensityPlot[matrix]works too bad as can be seen using a 3D chart< False,ColorFunction->(GrayLevel[(#-min)/(max-min)]&)];The question: is it a bug or I lost something in the way? A similar problem arises with many matrices that I generated in which there are many numbres close to zero.Well here is the matrix. Sorry because of the horrible formatmatrix={{0.024880970532441947`,0.13578975670808227`, 0.027812229119535358`, 0.0033045651867030673`,0.0003347493056088158`, 0.000026302686284994582`, 0.00004371748398547436`,0.00003681120741920656`, 0.00003087537872290685`, 0.00001905600654956626`,0.000011958703618226977`, 5.517957585379249`*^-6, 1.8928075271017263`*^-6,5.269301156366419`*^-7, 6.489638911064354`*^-8},{0.13578975670808227`, 0.9373917995816773`, 0.19133899349592184`,0.02294180236292207`, 0.002146876534122984`, 0.00002231000770522592`,0.0001344726022920243`, 0.00012287370329599313`, 0.00011865976751467771`,0.00008588847348107676`, 0.0000650218873670948`, 0.00003769993910579926`,0.000017332922552971424`, 7.275477707153364`*^-6, 1.801352169404378`*^-6},{0.027812229119535358`, 0.19133899349592184`, 0.03906478452215391`,0.004681738877149381`, 0.0004385133576867982`, 4.090272132604937`*^-6,0.000027823395408896714`, 0.000025374358467023346`,0.00002443091259330744`, 0.0000176320249591744`, 0.000013309659796768249`,7.69480720132288`*^- 6,3.5276710986778535`*^-6, 1.47654392225098`*^-6,3.645535247058728`*^-7},{ 0.0033045651867030673`, 0.02294180236292207`,0.004681738877149381`, 0.0005797298493723746`, 0.000052839536129011784`,4.7226000276470905`*^- 7,3.368374620650723`*^-6, 3.069745381714908`*^-6,2.952410460102803`*^- 6,2.12852330993168`*^-6, 1.605032461433652`*^-6,9.269514851713523`*^- 7,4.2451346697061517`*^-7, 1.7749887062983138`*^-7,4.377821687374563`*^-8},{ 0.0003347493056088158`, 0.002146876534122984`,0.0004385133576867982`, 0.000052839536129011784`, 9.255816438202384`*^-6,4.1249326083329274`*^- 8,3.0266675833749047`*^-7, 2.757224026816698`*^-7,2.650178380130713`*^- 7,1.9094596136360029`*^-7, 1.43896434791398`*^-7,8.305350785567792`*^- 8,3.801262097259811`*^-8, 1.588429369111028`*^-8, 3.915317215838556`*^-9},{0.000026302686284994582`, 0.00002231000770522592`,4.090272132604937`*^- 6,4.7226000276470905`*^-7, 4.1249326083329274`*^-8,3.535859690725517`*^- 6,2.1961201225893756`*^-8, 2.0000362799666382`*^-8,1.92152398727093`*^- 8,1.3838515977742497`*^-8, 1.0424076404006913`*^-8,6.0138740883614725`*^- 9,2.7512702310528075`*^-9, 1.1491658404200648`*^-9, 2.831335936719118`*^-10},{0.00004371748398547436`, 0.0001344726022920243`,0.000027823395408896714`, 3.368374620650723`*^-6, 3.0266675833749047`*^-7,2.1961201225893756`*^- 8,1.3721693600020958`*^-6, 1.2199036050151096`*^-9,1.17158414848564`*^- 9,8.434512469918671`*^-10, 6.351128550113803`*^-10,3.6627785449735637`*^-10, 1.675069186742091`*^-10,6.993998508257666`*^-11, 1.7225733012431472`*^-11},{0.00003681120741920656`, 0.00012287370329599313`,0.000025374358467023346`, 3.069745381714908`*^-6, 2.757224026816698`*^-7,2.0000362799666382`*^- 8,1.2199036050151096`*^-9, 5.794192640789079`*^-7,6.135409523313631`*^- 11,4.4155949418835226`*^-11, 3.3238340437588365`*^-11,1.916277391009494`*^-11, 8.760720928814635`*^-12,3.6567233858746355`*^-12, 9.003344351753371`*^-13},{0.00003087537872290685`, 0.00011865976751467771`,0.00002443091259330744`, 2.952410460102803`*^-6, 2.650178380130713`*^-7,1.92152398727093`*^-8,1.17158414848564 `*^-9, 6.135409523313631`*^-11,2.6403332491754`*^- 7,2.0055352842629293`*^-12, 1.509195581203532`*^-12,8.698207176501544`*^- 13,3.975359904169974`*^-13, 1.6587999868150363`*^-13, 4.0829224450233844`*^-14},{0.00001905600654956626`, 0.00008588847348107676`,0.0000176320249591744`, 2.12852330993168`*^-6, 1.9094596136360029`*^-7,1.3838515977742497`*^- 8,8.434512469918671`*^-10, 4.4155949418835226`*^-11,2.0055352842629293`*^- 12,7.78759863903862`*^-8, 5.953442715856466`*^-14,3.4301675965039096`*^-14, 1.567201965631006`*^-14,6.53740694684916`*^-15, 1.6085914870370433`*^-15},{0.000011958703618226977`, 0.0000650218873670948`,0.000013309659796768249`, 1.605032461433652`*^-6, 1.43896434791398`*^-7,1.0424076404006913`*^- 8,6.351128550113803`*^-10, 3.3238340437588365`*^-11,1.509195581203532`*^-12, 5.953442715856466`*^-14,2.9305747143573262`*^-8, 1.1656559281957215`*^-15,5.323917587243905`*^-16, 2.2200368196954134`*^-16, 5.4608078423152933`*^-17},{5.517957585379249`*^-6, 0.00003769993910579926`,7.69480720132288`*^- 6,9.269514851713523`*^-7, 8.305350785567792`*^-8,6.0138740883614725`*^- 9,3.6627785449735637`*^-10, 1.916277391009494`*^-11,8.698207176501544`*^-13, 3.4301675965039096`*^-14,1.1656559281957215`*^- 15,7.76299670479757`*^-9, 1.5221789994509213`*^-17,6.345037635961268`*^-18, 1.5602293071790306`*^-18},{1.8928075271017263`*^-6, 0.000017332922552971424`,3.5276710986778535`*^-6, 4.2451346697061517`*^-7,3.801262097259811`*^- 8,2.7512702310528075`*^-9, 1.675069186742091`*^-10,8.760720928814635`*^- 12,3.975359904169974`*^-13, 1.567201965631006`*^-14,5.323917587243905`*^-16, 1.5221789994509213`*^-17,1.6163732178696085`*^-9, 1.4386200807791453`*^-19, 3.530345878524741`*^-20},{5.269301156366419`*^- 7,7.275477707153364`*^-6, 1.47654392225098`*^-6,1.7749887062983138`*^- 7,1.588429369111028`*^-8, 1.1491658404200648`*^-9,6.993998508257666`*^-11, 3.6567233858746355`*^-12,1.6587999868150363`*^-13, 6.53740694684916`*^-15,2.2200368196954134`*^- 16,6.345037635961268`*^-18, 1.4386200807791453`*^-19,3.740548209112563`*^-10, 6.532730362808272`*^-22},{6.489638911064354`*^- 8,1.801352169404378`*^-6, 3.645535247058728`*^-7,4.377821687374563`*^- 8,3.915317215838556`*^-9, 2.831335936719118`*^-10,1.7225733012431472`*^-11, 9.003344351753371`*^-13,4.0829224450233844`*^-14, 1.6085914870370433`*^-15,5.4608078423152933`*^-17, 1.5602293071790306`*^-18,3.530345878524741`*^-20, 6.532730362808272`*^-22,4.517936598686041`*^-11}} ==== Has anyone used CalculationCenter 2.0? ==== >Hi,Mathematica functions such as LinearSolve, LinearProgramming,>FindMinimum and many others, sometimes cannot perform the>requested task. (The linear system of equations has no solution, the>linear program has no feasible points, etc.)and then returns the expression it tried to evaluate. This happens,>for example, with LinearSolve[{{1, 2}, {3, 4}, {5, 6}}, {-1, 2, -3}].This may be reasonable when only one such calculation is performed.>But, suppose we write a program that has to solve many linear>programs, some of them without a feasible solution. When there is>no solution, we want to take an appropriate action.What is the recommended way of calling a function like>LinearProgramming and getting an indication that somethingIt is possible to catch errors using ÔCheck'. But, as far as I>using ÔOff'.of the expression returned to see if it the name of the function called.>For example:Off[LinearSolve::nosol] ;If[ SameQ[ Head[sol = LinearSolve[...]] , LinearSolve] ,> (* The calculation failed. *) ,> (* sol is a solution. *) ](Note that we have to put sol = LinearSolve[...] insidesol = LinearSolve[...] ;>If[ SameQ[Head[sol],LinearSolve] , ... , ... ]then in case of failure, the failed calculation will be>attempted again!)Is there a cleaner solution?Uri------------------------------------------------- -------------------->| Prof. Uri Zwick | http://www.cs.tau.ac.il/~zwick |>| Dept. of Computer Science | zwick@post.tau.ac.il |>| ISRAEL | FAX: +972 3 6409357 |>----------------------------------------------------------- ----------It is not true that the LinearSolve is reevaluated when you test the Head. In[1]:=Timing[sol=LinearSolve[{{1,3},{2,6}},{1,1}]] LinearSolve::nosol: Linear equation encountered which has no solution.Out[1]={0.02 Second,LinearSolve[{{1,3},{2,6}},{1,1}]}In[2]:=Timing[Head[ sol]===LinearSolve]Out[2]={0. Second,True}Even if it was reevaluated, the value is cached so very little time is lost.In[3]:=Timing[LinearSolve[{{1,3},{2,6}},{1,1}]] LinearSolve::nosol: Linear equation encountered which has no solution.Out[3]={0. Second,LinearSolve[{{1,3},{2,6}},{1,1}]}So testing the head of the result is a fine method for error checking.---------------------------------------------------- ----------Omega ConsultingThe final answer to your Mathematica needshttp://omegaconsultinggroup.comReply-To: b0risNO@SPAMgmx_de.replaceunderscore ==== Mathematica run on my system?Boris Hollas ==== >Hi everybody,If I have 9 points in a 2 dimensional space how do I decide if they>fit better a linear function or a logarithmic function?>JayJay,The first question to answer is, Do I needto interpolate the data or just approximate it?If the data is the result of physical experiments orfor some reason has a random error componentto it, there is no reason to interpolate the dataexactly. If the data is deterministic, ie if youperformed the experiment again you would getexactly the same answer, you would want to interpolatethe data.The answer to this question directs the selection of possiblefunction families to approximate the process that is representedby the data you have sampled.If your data has random error, it is non-deterministic,you will want to select an approximating function. One way to dothis is to use the Statistics`LinearRegression` package and the Regressfunction. Given a set of functions to fit, this function will return thecoefficients of the functions, the quality of fit of the model and theimportance of each function in the model.If you want to fit nonlinear functions such as 2^x, you can usethe Statistics`NonlinearFit` package and the NonlinearRegressfunction. I would recommend sticking to the LinearRegressionpackage and perform the nonlinear transformation on the yvalues instead. The primary reason for this is efficiency in calculatingthe optimal coefficients. NonlinearRegress requires an iterative optimizationwhile Regress has a closed-form solution.If you need to interpolate the data, there are many options available.The easiest to use is the standard function Interpolation. This functionwill fit a spline between the points of any order you specify. The limitationof this routine is your data must be on a cartesian grid. If this is not the case,and you have 2D data you can use a triangulation of the data to fit a planeto each region defined by its three closest neighbors. I do not have the latest versionof Mathematica, but I believe there is a function that supports this directly now.The last options for interpolation, especially for 2D+ data is to usespatial correlation functions. These include radial basis functions andkriging functions. In general, these functions assume nearby points havesome inßuence on the prediction of an unknown location. The amount of inßuencebecomes a function of the distance from all of the known points.These functions can provide a great deal of ßexibility in fitting data,but they are more complex to use and in the case of kriging, difficultto fit. Kriging requires an optimization process to determine the parametersfor the model that control the range of inßuence of nearby points andthe smoothness of the resulting surface.I have probably confused you more than helped with my long-windedanswer, but I hope it helps you address your problem.Jay MartinPenn State University ==== It must be easy but how do I add line/curve thickness inParametricPlot3D as inParametericPlot3D[{Cos[t], Sin[t], 1}, {t,0, 2Pi}];Can AbsoluteThickness[2] be added to the above line somehow, somewhere?Xiangdong Liu ==== Is not possible to select/click on ParametricPlot3D output image and drag mouse to directly rotate/view the geometrric views on-- To contact in private, remove ==== Bill,The removal of labels on closing a notebook is controled by the cell optionCellLabelAutoDelete (see Option Inspector).The connection between In[n], Out[n] and memory lasts until the kernel isquit.--Allan---------------------Allan HayesMathematica Training and ConsultingLeicester UKhay@haystack.demon.co.ukVoice: +44 (0)116 271 4198 >Why when I save a notebook, the input output disappears? I assume the input output disappears means the In[n] and Out[n] thatappears to the left of an expression after it is evaluated by Mathematica. Ialso assume, by save you mean save, *close* then re-open the particularnotebook. Basically, the In[] and Out[] are pointers to memory where the results ofan expression reside. While you have the notebook open (before closing it)there is a clear link between the contents of memory and expressions in thatnotebook that have been executed. Once the notebook is closed, that link issevered. There is no practical way to re-link expressions in a notebook tothe location in memory where the results are once the notebook as beenclosed. >Is there any way to correct this? Assuming I've understood your question properly, no. But I am curious asto what you are trying to do that prompts the question.> ==== >Why when I save a notebook, the input output disappears? Is there any way>to correct this?PauloThis is due to a front end option, CellLabelAutoDelete. By default, it is set to True. If you leave the cell labels in a nb, it's hard to determine if a cell was evaluated in the current session or a previous session.You can set this option for the notebook. Open the option inspector. Change the scope/set option values for to notebook. And change Cell Options->Cell Labels->CellLabelAutoDelete to False.Also, there are some stylesheets that already have this setting: ArticleClassic, ArticleModern, HelpBrowser, TextBook, and TutorialBook. I think the rationale is that these are for publishing.-------------------------------------------------- ------------Omega ConsultingThe final answer to your Mathematica needshttp://omegaconsultinggroup.com ==== The answer to the last Ashraf's last question is mathematically rather uninteresting: in Mathematica Limit[f[x], x -> 0] *means* Limit[f[x], x -> 0, Direction -> -1].As for the other points, well it is true that even the one sided limits of 1/x do not exist if a limit is required to be a real number. But it is often convenient to consider the extended real line with two additional points, called -Infinity and Infinity (one speaks of compactifying the real line, which then becomes topologically equivalent to a closed interval). This can be made perfectly rigorous, although of course the object thus obtained is no longer a field in the algebraic sense (in other words, you can't perform usual arithmetic with Infinity and -Infinity).Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/> Ashraf, Strictly speaking you are correct. The limit does not exist. But there > is> such a thing as a one-sided limit, which is not a true limit but still> useful. In this case even the one-sided limits do not really exist because the> result is unbounded. But again, it is useful to signify this by saying > that> the limit is infinite. So it is rather loose language by both > mathematicians> and Mathematica. Perhaps one of the mathematicians in the group will give you a fuller> explanation. David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/ To: mathgroup@smc.vnet.net Dear all,> One thing I've noticed that if we have a function which has two > different> limits (given two different directions) at one points , mathematica > would be> still give an answer though to my understanding the limit doesn't > exist in> such a case. Consider the following example:> a[x_]:=1/x Limit[a[x],x->0,Direction->+1] +Inf Limit[a[x],x->0,Direction->+1] -Inf Limit[a[x],x->0]. +Inf.... Maybe my calculus knowledge is a > bit> rusty but does the limit exist in this case??> ==== > Ashraf, Strictly speaking you are correct. The limit does not exist.It doesn't exist _in the real or complex number systems_, true. However, ifone deals with the projective extension (one-point compactification) ofeither the reals or complexes, then the limit does actually exist.> But there is such a thing as a one-sided limit, which is not a true limit> but still useful.Correct if, by true limit, you mean a limit which is independent of thedirection of approach.> In this case even the one-sided limits do not really exist because the> result is unbounded.Ha, ha. Yes, they do not _real_ly exist; that is, they do not exist in thereal number system. Indeed, in an introductory calculus course dealing withthe reals, whenever one says that a limit is +oo or is -oo, one isnot actually speaking of the limit existing at all. Rather, one is merelyindicating that the limit fails to exist because the function increases ordecreases without bound.However, if we use the affine extension (two-point compactification) ofthe reals, then the unilateral (one-sided) limits actually do exist. AndMathematica does these correctly.> But again, it is useful to signify this by saying that the limit is> infinite. So it is rather loose language by both mathematicians and> Mathematica.Regarding rather loose language on the part of mathematicians:I must agree with you _if_ the context is that of strictly the reals orcomplexes. It is surely confusing to some students for us to say that acertain limit _is_ ... while we actually mean that the limit fails toexist. It seems duplicitous.That's why I prefer to deal with appropriate extensions of the reals orcomplexes. Then, whenever we say that a limit _is_ ..., it truly is!It is quite regrettable that the documentation for Limit doesn't makecompletely obvious the fact that, in absence of a specified Direction,a default Direction is assumed! (Or did I just miss the bold type someplacewarning about that?)And it's unfortunate IMO that Mathematica's Limit, in absence of aspecified Direction, doesn't give the omnidirectional limit. For theproblem at hand: If we deal with the projective extension of the complexes,the omnidirectional limit of 1/x as x -> 0 is, truly is, ComplexInfinity.David Cantrell ==== What you want, probably, is a least squares fit, and then decide bywhichever one gives you the smallest residual. The least-squares fit picks afunction, e.g. a+b x. Then, given (a,b) computes the sum of the squares ofthe difference between your data points and the straight line. Then you seekthose parameters (a,b) which minimize the resulting sum (residual). Here issome code to do that. lsfit takes two arguments (a,b) and returns theresidual, FindMinimum then minimizes. The output of FindMinimum is theresidual and two rules with the best (a,b). Substitute your own function forf[x_] in the body of lsfit.Kevindata = Table[{x, Sqrt[x]},{x, 1., 3., 0.25}]Plus @@ Apply[(f[#1] - #2)^2 & , data, {1}]lsfit[(p_)?NumberQ, (q_)?NumberQ] :=Module[{soln, f}, f[x_] := p + q*x;Plus @@ Apply[(f[#1] - #2)^2 & , data,{1}]]lsfit[1, 1]FindMinimum[lsfit[a, b], {a, -2, 2},{b, -2, 2}]lsfit[(p_)?NumberQ, (q_)?NumberQ] :=Module[{soln, f}, f[x_] := p + q*Log[x];Plus @@ Apply[(f[#1] - #2)^2 & , data,{1}]]FindMinimum[lsfit[a, b], {a, -2, 2},{b, -2, 2}]> Hi everybody, If I have 9 points in a 2 dimensional space how do I decide if they> fit better a linear function or a logarithmic function?> Jay>Reply-To: drbob@bigfoot.com ==== Use regression and choose the model that minimizes the sum of squared errors (or some other measure of total error, if you prefer).Here's a bit of sample data, three possible models, and the sum of squared error for each:data = {#, Random[] + 0.3Log@# + 0.2#} & /@ Range[9]{x, y} = Transpose@data;Fit[data, {1, Log@q}, q]error = #.# &[(% /. q -> x) - y]Fit[data, {1, q}, q]error = #.# &[(% /. q -> x) - y]Fit[data, {1, q, Log@q}, q]error = #.# &[(% /. q -> x) - y]BobbyOn Wed, 12 Feb 2003 03:54:03 -0500 (EST), jay Johnson Hi everybody, If I have 9 points in a 2 dimensional space how do I decide if they> fit better a linear function or a logarithmic function?> Jay-- majort@cox-internet.comBobby R. Treat ==== >If I have 9 points in a 2 dimensional space how do I decide if they>fit better a linear function or a logarithmic function?One choice would be to use the sum of the errors squared. For example:First create some data.In[1]:=data=Table[{Random[],Random[]},{9}]Out[1]={{ 0.944293,0.933087},{0.835982,0.570568},{ 0.510525,0.861731},{0.624458,0.318239},{ 0.795989,0.2449},{0.622892,0.216268},{0.150898,0.567541},{ 0.41438,0.0978371},{0.17643,0.920655}}do a linear fitIn[2]:=f=Fit[data,{1,x},x]Out[2]=0.573502[InvisibleSpace] -0.0848516 xdo a logarithmic fitIn[4]:=g=Fit[data,{1 Log[x]},x]Out[4]=-0.455209 Log[x]Sum the squared errors for the linear fitIn[3]:=Tr[((#1[[2]] - f /. x -> #1[[1]])^2 & ) /@ data]Out[3]=0.834833sum the squared errors for the logarithmic fitIn[5]:=Tr[((#1[[2]] - g /. x -> #1[[1]])^2 & ) /@ data]Out[5]=1.59636Since sum of the squared errors for the logarithmic fit is greater than for the linear fit, conclude the linear fit is better.Note, using the sum of the squared errors is probably the most commonly used measure of goodness of fit, but it is not the only measure that could be used. I've used this measure since that is what Fit minimizes to compute the fit coefficients.Also, if you want to compare several different models using a least squares fit, it would probably be better to use the Regress function in the package Statistics`LinearRegression` . There are options for this function to include in the output the sum of the error squared as well as other statistics to judge the fit of the model to the data.Finally, if you are going to be fitting models to data often it would be a good idea to read a good text on fitting models to data. There are several pitfalls that can lead to very misleading results. A couple of possilbe texts areFitting Equations to Data by Daniel and WoodApplied Linear Regression by Weisberg ==== I want to insert a notebook in a LaTeX document. I installed thecorresponding files according to:http://support.wolfram.com/mathematica/systems/next/ fontsnotprinting.htmlI'm getting no output. LaTeX seems to run fine but Dvips gives someerrors: .87 checksum mismatch in zwcmb .87 checksum mismatch in zwcmm .87 Error: module writet1 (file Math1Mono-Bold.pfa): .87 CharStrings dict: more entries than dict size (223)When I then launch GSview, it gives a DSC error, it asks me if I wantto Accept, Cancel or Ignore DSC comments and I get a blank page.In case it is of any use, I'm using the latest version of MikTeX.Can someone help?miz. ==== Hi all,I've got a question to Mathematicas' functions/possibilities to export datato files.I want to create in Mathematica different Vectors (=tables) and Matrixes andI also want to do some calculations with them in Mathematica.At the end, I want to export the data (the inputs and results) into a fileto access them in C. It's to test my C routines.How can I do this? I don't want to write into textfiles and use the Cfunctions like fscanf,... Are there other ways?Such like I write from Mathematica to a file:ßoat any_name[] = { data separated with comma..};Has anyone an idea?TIA,Jochen ==== Ye Hu,Yes, Mathematica returns the complex value which Plot can't handle. But youcan get it to return the real value by loading the package...<< Miscellaneous`RealOnly`Plot[x^(2/3), {x, -1, 0}]Ted Ersek also has a package, SwitchableRealOnly, on MathSource that allowsyou to turn the feature off and on.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ ==== I'd like to detrmine Grad to a function so i go:< LetMV> g = Sqrt[1+x^(2a)]-x^aMV> where if we put the parameter a to be 2 we recover the original function, f.MV> Now,MV> Integrate[g,{x,0,Infinity}] /. a->2MV> gives the correct answerIn[1] := Integrate[Sqrt[1 + x^(2a)] - x^a, {x, 0, Infinity}] /. a -> 2/3Out[1] = -(Gamma[-5/4]*Gamma[7/4])/(2*Sqrt[Pi]) (* <- INVALID *)In[2] := N[%]Out[2] = -1.01666Actually this integral, obviously, diverges to the plus infinity.In[3] := N[Integrate[Sqrt[1 + x^(2a)] - x^a, {x, 0, 10^10}] /. a -> 2/3]Out[3] = 3232.Best wishes,Vladimir BondarenkoMathematical and Production DirectorSymbolic Testing GroupWeb : Self-censorship: Steve will edit it out all the same ;-) http://www.CAS-testing.org/ GEMM Project (95% ready) Mail : 76 Zalesskaya Str, Simferopol, Crimea, Ukraine ==== andresult = Solve[{a == 1/(1/r2 + 1/50), 50 == 1/(1/(a + r1) + 1/r2)}, r1,a]Plot[Evaluate[r1 /. result], {r2, -25, 25}]works fine. Jens> I'd sure like to find out how to clean up a process I do a lot. Namely, get> a solution to some set of equations and then plot the result. For example,> I recently did> result = Solve[{a == 1/(1/r2 + 1/50), 50 == 1/(1/(a + r1) + 1/r2)}, r1, a]> This gives {{r1 -> (a function of r2) }}> Then, I plot it by> Plot[ (this function of r2), {r2, startvalue, stopvalue}]> where I carefully type in this function. I feel sure you Mathematica pros> don't have to do that so I have made several feeble attempts to automate> this over the years. They fail because I still don't have a clue how Mathematica works.> Here's my last attempt:> Plot[ result /. %]> Mathematica just hisses and prints out tons of error messages, none of which mean> a thing to me.> Surely there is a way to get this plot without having to type the Solve[] result> into Plot[]. Any hints would be appreciated, as usual.> Rob ==== > Plot[ result /. %]Plot[f, {x, xmin, xmax}]?In one cell the following works for me, did you put in the limits of theplot.result = Solve[{a == 1/(1/r2 + 1/50), 50 == 1/(1/(a + r1) + 1/r2)}, r1, a];Plot[r1 /. %, {r2, 1, 2}];-- NigelReply-To: kuska@informatik.uni-leipzig.de ==== what is withFindPrimes[n_Integer] := Select[Table[i, {i, n^2, (n + 1)^2}], PrimeQ] Jens> Folks,> I am trying to come up with a snazzy way to hunt for a prime between n^2 and> (n+1)^2.> Some ideas?> --> ==== =================================================> God made the integers, all else is the work of man.> L. Kronecker, Jahresber. DMV 2, S. 19.Reply-To: kuska@informatik.uni-leipzig.de ==== try FullForm to see all digits of a ßoating point numberthat is truncated by the Print/Output functions. Jens> I tried some of my Mathematica3.01 programs on a computer with> Mathematica4.1,> there where some differences that I could not explain.> Regarding N[]: consider for example:> with version 4.1 I got:> N[Sqrt[2.],16]->1.4142> and> N[Sqrt[2.],17]->1.4142135623730950> and in version 3.01:> N[Sqrt[2.],16]->1.414213562373095> and> N[Sqrt[2.],17]->1.4142135623730950> Using SetPrecision[Sqrt[2.],16] I could make Mathematica4.1 give me 16> digits precision.> Ideas?> Peter WReply-To: kuska@informatik.uni-leipzig.de ==== you must set the seed-value for the random number generatorbefore you start the generator. In Mathematica this is done withSeedRandom[n] resets the pseudorandom number generator, using the integer n as a seed. SeedRandom[ ] resets the generator, using as a seed the time of day. Jens> I have a program which uses a random number in several places - the same> number in a given run of the program. When I implement the program however> the number changes in every new call to it. I've tried to overcome this> using Which, Hold, Verbatim, and others, all to no avail. Any help> greatly appreciated. ==== Dear all,Suppose I create a function f[x_,opts___]with optionsShape in {Circle, Ellipsis} and Diameter in R+, DiameterLong in R+,DiameterShort in R+Say that the defaults areOptions[x]={Shape->Circle, Diameter->1.}The option Diameter makes sence only when Shape->Circle, andThe options DiameterShort/Long make sense only when Shape->EllipsisIs there a quick way to tell Mathematica to warn if these conditions arenot satisfied? I could write a series of boolean tests, but I was wonderingif there is a more elegant way.Best,Kyriakos_____+**+____+**+___+**+__+**+_Kyriakos ChourdakisLecturer in Financial EconomicsURL: http://www.qmw.ac.uk/~te9001tel: (++44) (+20) 7882 5086Dept of EconomicsUniversity of London, QMLondon E1 4NSU.K.Reply-To: kuska@informatik.uni-leipzig.de ==== can you explain how you simple example was obtained ? Jens> I want to make a matrix of derivations, so I will be able to multiply> it by a matrix of functions and get the result matrix> simple example:> |d/dx 0 | |xy x| |y 1|> | |.| |=| |> |d/dy d/dx| |x+y 3| |x+1 0|> thank youReply-To: kuska@informatik.uni-leipzig.de ==== a interpolation gives for the data x[i], y[i] at everypoint x[i] the original y[i], a fit must not do that. Jens> Another in a series of potentially simple questions:> What is the difference between using Fit and Interpolation?> f[x_]=Fit[data, {1,x},x]> -or-> f[x_]=Interpolation[data][x]> I do know that Fit can take arguments for the independant variables> form like:> f[x_]=Fit[data, {1,x},x]> f[x_]=Fit[data, {1,x,x^2},x]> but that's a bit of guesswork if you have a limited set of points, no?> Also, is there a function in Mathematica that allows me to swap> dependent and independent variables? e.g. x=2.5y --> y=x/2.5> David Seruyange> Student ==== Ray,The suggestion that I previously posted should have used Get (as Bob Hanlondid) instead ofNeeds.With Needs, On[RealOnly] does not load the package Miscellaneous`RealOnly`when use a second time, and in particular after using Off[RealOnly] ---thisis because Miscellaneous`RealOnly` will be in the list $Packages.Here is the corrected version,RealOnly /: On[RealOnly] := Get[ Miscellaneous`RealOnly`];RealOnly /: Off[RealOnly] := (Unprotect[Power, Solve, Roots]; Clear[Power, Solve, Roots]; Protect[Power, Solve, Roots]; Remove[Miscellaneous`RealOnly`Nonreal]; $Post =. )>> If I activate < want real values, how can I get rid of it so I can do a different> calculation involving complex values. In other words, how do I close the> RealOnly function. Is there another way of doing a calculation that will> Ray,> Here is a modification of a posting by Bob Hanlon in Sept 2000.> RealOnly /: On[RealOnly] :=> Needs[ Miscellaneous`RealOnly`];>> RealOnly /: Off[RealOnly] :=> (Unprotect[Power, Solve, Roots]; Clear[Power, Solve,> Roots]; Protect[Power, Solve, Roots];> Remove[Miscellaneous`RealOnly`Nonreal]; $Post =. )>> Check>> (-1.)^(1/3)>> 0.5 + 0.8660254037844387*I>> On[RealOnly]> (-1.)^(1/3)>> -1.>> Off[RealOnly]> (-1.)^(1/3)>> 0.5 + 0.8660254037844387*I> --> Allan>> ---------------------> Allan Hayes> Mathematica Training and Consulting> Leicester UK> hay@haystack.demon.co.uk> Voice: +44 (0)116 271 4198>>Reply-To: kuska@informatik.uni-leipzig.de ==== http://library.wolfram.com /database/MathSource/560/ Jens> If I activate < want real values, how can I get rid of it so I can do a different> calculation involving complex values. In other words, how do I close the> RealOnly function. Is there another way of doing a calculation that will ==== When your first matrix is a matrix of functions, then the dot productresults in a matrix of sums of products of arguments and functions. A simplesubstitution then will give you the result you are looking for.In[1]:=mat1 = {{D[#1, x] & , 0 & }, {D[#1, y] & , D[#1, x] & }}Out[1]={{D[#1, x] & , 0 & }, {D[#1, y] & , D[#1, x] & }}In[2]:=mat2 = {{x*y, x}, {x + y, 3}}Out[2]={{x*y, x}, {x + y, 3}}In[3]:=mat1 . mat2 /. a_.*b_Function -> b[a]Out[3]={{y, 1}, {1 + x, 0}}Fred SimonsEindhoven University of Technology> -----Original Message-----> Sent: maandag 3 februari 2003 7:08> To: mathgroup@smc.vnet.net> I want to make a matrix of derivations, so I will be able to multiply> it by a matrix of functions and get the result matrix> simple example:> |d/dx 0 | |xy x| |y 1|> | |.| |=| |> |d/dy d/dx| |x+y 3| |x+1 0|> thank you> ==== > I want to make a matrix of derivations, so I will be able to multiply> it by a matrix of functions and get the result matrix> simple example:>> |d/dx 0 | |xy x| |y 1|> | |.| |=| |> |d/dy d/dx| |x+y 3| |x+1 0|>> thank you>Inner[#1[#2]&, {{D[#, x]&, #*0&},{D[#, y]&, D[#, x]&}}, {{x*y, x}, {x + y, 3}}, Plus]{{y, 1}, {1 + x, 0}}orInner[D[#2,#1]&, {{x, Unique[]},{y, x}}, {{x*y, x},{x + y, 3}}, Plus]{{y, 1}, {1 + x, 0}}Bob Hanlon ==== How can I (vertically) align several Plots (graphs) in theGraphicsArray to have y axis in the same x position?Somehing like plots = Table[Plot[Sin[i x], {x, 1, [Pi]}], {i, 1, 3}];Show[GraphicsArray[Partition[plots, 1], GraphicsSpacing -> {1, -0.1}]]And how can I impose the AspectRatio of the individual graphs to havex axis spanning the whole x resolution and y axis only one third of yresolution?Cyril Fischer ==== >> I have a program which uses a random number in several places - the>> same>> number in a given run of the program. When I implement the program>> however>> the number changes in every new call to it. I've tried to overcome>> this>> using Which, Hold, Verbatim, and others, all to no avail. Any>> help>> greatly appreciated.>> This is what SeedRandom is for, e.g.> SeedRandom[5];Table[Random[Integer,{1,10}],{3}]> {2,3,2}>> Now evaluating again:> SeedRandom[5];Table[Random[Integer,{1,10}],{3}]> {2,3,2}> Andrzej Kozlowski> Yokohama, Japan> http://www.mimuw.edu.pl/~akoz/> http://platon.c.u-tokyo.ac.jp/andrzej/>> suggested. There is some difficulty. If I try>> F[n_]= SeedRandom;Table[Random[Real,{-1,1}],{n}]>> with n=5, say, I get an error message. I don't know how to fix this.>> Don Darling.>>You need to use a seed with SeedRandom and you need to enclose the composite statement in parentheses:F[n_] := (SeedRandom[5]; Table[Random[Real, {-1, 1}], {n}])Now look:In[6]:=F[3]Out[6]={0.573197,0.696679,0.225655}In[7]:=F[5 ]Out[7]={0.573197,0.696679,0.225655,-0.203925,-0.523976}Each random sequence will be an extension of shorter ones.Andrzej KozlowskiYokohama, Japanhttp://www.mimuw.edu.pl/~akoz/http:// platon.c.u-tokyo.ac.jp/andrzej/ ==== Alan,The error message occurs because the NIntegrate within ComplicatedF iscomplaining about its input. For some reason, the MonteCarlo NIntegrate isexamining the quantity ComplicatedF[x] where x is not numerical. Tryinputting simply ComplicatedF[x] and you will see the same error message.The way to avoid this situation is to change the function by restricting itsinput to only numeric quantities:Clear[ComplicatedF]ComplicatedF[x_?NumericQ] := Re [NIntegrate [E^(- (I x+y+I)^2), {y,0,1}] ]Now try your Monte Carlo integration and you will see no errors.Carl WollPhysics DeptU of Washington> I have a rather complicated function that Mathematica can't seem to handle> with> NIntegrate, Method->MonteCarlo.>> This is not my function, but it shows the essence of the problem.> Suppose we have>> ComplicatedF[x_] := Re [NIntegrate [E^(- (I x+y+I)^2), {y,0,1}] ]>> Then, if you try:>> NIntegrate[ComplicatedF[x], {x,0,2}, Method->MonteCarlo]>> Mathematica will complain that the integrand is not numerical.> But of course it is numerical and removing the Method->MonteCarlo option> will generate an answer.>> Now my actual function is quite complicated which is why> I want to try the MonteCarlo method. Any suggestions?>>Reply-To: kuska@informatik.uni-leipzig.de ==== and preventing the evaluation of ComplicatedF[] for symbolicarguments withComplicatedF[x_?NumericQ] := Re[NIntegrate[E^(-(I x + y + I)^2), {y, 0,1}]];NIntegrate[ComplicatedF[x], {x, 0, 2}, Method -> MonteCarlo]work with out an error message. Jens> I have a rather complicated function that Mathematica can't seem to handle> with> NIntegrate, Method->MonteCarlo.> This is not my function, but it shows the essence of the problem.> Suppose we have> ComplicatedF[x_] := Re [NIntegrate [E^(- (I x+y+I)^2), {y,0,1}] ]> Then, if you try:> NIntegrate[ComplicatedF[x], {x,0,2}, Method->MonteCarlo]> Mathematica will complain that the integrand is not numerical.> But of course it is numerical and removing the Method->MonteCarlo option> will generate an answer.> Now my actual function is quite complicated which is why> I want to try the MonteCarlo method. Any suggestions? ==== it seems I have a simple problem, but I cannot find a (simple)solution:if I type 2^^1000111 mathematica calculates the correct dec. numberbut if I type: base=2; number=1000111; base^^number all I get is a errormessage ???So a function Convert[number_,base_] for base convertions cannot work ...Any ideasThxWerner--********************************************* ******************************Prof. Mag. Werner CYRMONHTBLuVA Wr. Neustadt Abt. EDVOhttp://edvowww.htlwrn.ac.at/cyx************************** *************************************************If you can imagine it, you can do it! Walt Disney******************************************************* ********************Want to learn math with fun or calculating some stuff online:Look at http://Onlinemath.htlwrn.ac.at ==== > i have a problem by creating a package. I need routines from another> packageI think that your second form of the package loading is correct: > BeginPackage[Seismo`Hazard`PSHA`,{Statistics` ContinuousDistributions`}]but you should use the full context with symbols inside your own package which are from Statistics`ContinuousDistributions`, e.g. writeStatistics`ContinuousDistributions` NormalDistributioninstead ofNormalDistributionThat's why you get the error message like> Random::randt: Type specification> Seismo`Hazard`PSHA`Private`NormalDistribution[<<19> , 0.16] in Random[<< 1 >>]> should be Real, Integer, or Complex.-- Antti Penttil.8a Antti.I.Penttila@invalid.helsinki.fi ==== Show::gtype: CartesianMap is not a type of graphics.Is it version realated? mine is V 2.2 -- Narasimham> My friend Rip Pelletier pointed me to a better method to> illustrate the> Cauchy-Riemann relations for analytic functions. He> pointed me to Tristan> Needham's book ÔVisual Complex Analysis'. In Chapter 5, Section I -> Cauchy-Riemann Revealed, the CR conditions are related to the complex> mapping.>> If a small patch of squares are mapped by an analytic> function, then they go> into another small patch in which all the squares have> been amplified and> rotated in exactly the same way.>> Fortunately, we have the ComplexMap package in Mathematica> and can easily> illustrate this for your functions. For example, for the> Sin function...>> Needs[ÔGraphics`ComplexMap`']>> With[> {x = 2,> y = 2,> del = 0.01,> f = Sin},> Show[GraphicsArray[{CartesianMap[> Identity, {x - del, x + del, del/5}, {y - del,> y + del, del/5},> Axes -> False,> DisplayFunction -> Identity],>> CartesianMap[> f, {x - del, x + del, del/5}, {y - del, y + del, del/5},> Axes -> False,> DisplayFunction -> Identity]}],> ImageSize -> 500]];>> A square patch maps into a rotated square patch. Just> change f and/or the> mapping points for other cases. Use a pure function for z^2.>> For a case that is not analytic, and so the CR relations> do not hold, use> f = # + 2Abs[#] &. The squares go to parallelograms.>> David Park> djmp@earthlink.net> http://home.earthlink.net/~djmp/> Is it possible to have a semi transparent view of surfaces> so that one> may verify slopes by ParametricPlot3D for Cauchy-Riemann relations?> The following is program for 3 functions Z^2, Z^3, Sin[Z].It was> expected to check slopes at the line of intersection of Re> and Im parts.>> R1=x^2-y^2 ; I1= 2 x y ;> z2r=Plot3D[R1 , {x,-Pi,Pi},{y,-Pi,Pi} ];> z2i=Plot3D[I1 , {x,-Pi,Pi},{y,-Pi,Pi} ];> Show[z2r,z2i] ; ÔTop view >> Re,Im Intxn';> Plot[{x ArcTan[-Sqrt[2]+1],x ArcTan[Sqrt[2]+1]}, {x,-Pi,Pi} ];>> R3=x^3 - 3 x y^2 ; I3= 3 x^2 y - y ^3 ;> z3r=Plot3D[R3 , {x,-Pi,Pi},{y,-Pi,Pi} ];> z3i=Plot3D[I3 , {x,-Pi,Pi},{y,-Pi,Pi} ];> Show[z3r,z3i] ; ÔTop view >> Re,Im Intxn';> Plot[{x,x (-Sqrt[3]+2) , x (-Sqrt[3]-2) }, {x,-Pi,Pi} ];>> R2=Cosh[y] Sin[x] ; I2=Sinh[y] Cos[x] ;> scr=Plot3D[R2,{x,-Pi/2,Pi/2},{y,-Pi/2,Pi/2}];> sci=Plot3D[I2,{x,-Pi/2,Pi/2},{y,-Pi/2,Pi/2}];> Show[scr,sci]; ÔTop view >> Re,Im Intxn';> Plot[{ArcTanh[Tan[x]]},{x,-Pi/2,Pi/2 }];-- To contact in private, remove Reply-To: kuska@informatik.uni-leipzig.de ==== Mathematica can't draw transparent surfaces but MathGL3d canGet[MathGL3d`OpenGLViewer`]MVShow3D[z2r, MVNewScene -> True, MVAlpha -> 0.5];MVShow3D[z2i, MVAlpha -> 0.5];you can get MathGL3d fromhttp://phong.informatik.uni-leipzig.de/~kuska/mathgl3dv3/ id3.htm Jens> Is it possible to have a semi transparent view of surfaces so that one> may verify slopes by ParametricPlot3D for Cauchy-Riemann relations?> The following is program for 3 functions Z^2, Z^3, Sin[Z].It was> expected to check slopes at the line of intersection of Re and Im parts.> R1=x^2-y^2 ; I1= 2 x y ;> z2r=Plot3D[R1 , {x,-Pi,Pi},{y,-Pi,Pi} ];> z2i=Plot3D[I1 , {x,-Pi,Pi},{y,-Pi,Pi} ];> Show[z2r,z2i] ; ÔTop view >> Re,Im Intxn';> Plot[{x ArcTan[-Sqrt[2]+1],x ArcTan[Sqrt[2]+1]}, {x,-Pi,Pi} ];> R3=x^3 - 3 x y^2 ; I3= 3 x^2 y - y ^3 ;> z3r=Plot3D[R3 , {x,-Pi,Pi},{y,-Pi,Pi} ];> z3i=Plot3D[I3 , {x,-Pi,Pi},{y,-Pi,Pi} ];> Show[z3r,z3i] ; ÔTop view >> Re,Im Intxn';> Plot[{x,x (-Sqrt[3]+2) , x (-Sqrt[3]-2) }, {x,-Pi,Pi} ];> R2=Cosh[y] Sin[x] ; I2=Sinh[y] Cos[x] ;> scr=Plot3D[R2,{x,-Pi/2,Pi/2},{y,-Pi/2,Pi/2}];> sci=Plot3D[I2,{x,-Pi/2,Pi/2},{y,-Pi/2,Pi/2}];> Show[scr,sci]; ÔTop view >> Re,Im Intxn';> Plot[{ArcTanh[Tan[x]]},{x,-Pi/2,Pi/2 }];> --> To contact in private, remove ==== When loading Combinatorica with < Calculus, Graphics, Statistics, and Personal (this with some private utilities).Emilio Martin-Serrano___________________________________ ==== One of the new features of Mathematica 4.2 are theXML tools and I have written an example of their usebased on SVG (an XML application for vector graphics).Tom Wickham-Jones CreatedBy='Mathematica 4.2' Mathematica-Compatible NotebookThis notebook can be used with any Mathematica-compatibleapplication, such as Mathematica, MathReader or Publicon. The datafor the notebook starts with the line containing stars above.To get the notebook into a Mathematica-compatible application, doone of the following:* Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application;* Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application.Data for notebooks contains only printable 7-bit ASCII and can beCR, LF or CRLF (Unix, Macintosh or MS-DOS style).NOTE: If you modify the data for this notebook not in a Mathematica-compatible application, you must delete the line below containingtry to use invalid cache data.For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com phone: +1-217-398-0700 (U.S.)Notebook reader applications are available free of charge from Wolfram Research.**************************************************** ***************)(* NotebookFileLineBreakTestNotebookFileLineBreakTest*)(* NotebookOptionsPosition[ 52820, 1633]*)(*NotebookOutlinePosition[ 53608, 1662]*)(* CellTagsIndexPosition[ 53538, 1656]*)(*WindowFrame->Normal*)Notebook[{Cell[TextData[{ Generating SVG with , StyleBox[Mathematica, FontSlant->Italic]}], Title],Cell[An example of the use of SymbolicXML, Subtitle],Cell[, Subsubtitle],Cell[CellGroupData[{Cell[What is SVG?, Section],Cell[TextData[{ SVG is an XML language for describing two-dimensional graphics. Since it is based on XML any XML aware application can work with SVG. , StyleBox[Mathematica, FontSlant->Italic], has some good tools for working with XML and some specific functions that support SVG, thus it is a good environment for some interesting SVG applications. SVG contains some interesting features including a variety of dynamic features such as animations.}], Text],Cell[TextData[{ SVG can be rendered with a browser plug-in from Adobe, , ButtonBox[http://www.adobe.com/svg, ButtonData:>{ URL[ http://www.adobe.com/svg], None}, ButtonStyle->Hyperlink], . which provides strong support including the animation functions. More information about SVG can be found at the W3C site: , ButtonBox[http://www.w3.org/Graphics/SVG/, ButtonData:>{ URL[ http://www.w3.org/Graphics/SVG/], None}, ButtonStyle->Hyperlink], .}], Text]}, Open ]],Cell[CellGroupData[{Cell[TextData[{ StyleBox[Mathematica, FontSlant->Italic], Commands for Generating SVG}], Section],Cell[TextData[{ StyleBox[Mathematica, FontSlant->Italic], has a rich graphics language for representing graphics as , StyleBox[Mathematica, FontSlant->Italic], expressions.}], Text],Cell[CellGroupData[{Cell[BoxData[ (p = Graphics[Line[ {{0, 0}, {1, 1}}]])], Input],Cell[BoxData[ TagBox[([SkeletonIndicator] Graphics [SkeletonIndicator]), False, Editable->False]], Output]}, Open ]],Cell[TextData[{ These print as expressions, if you want to see a graphical expression you use a command such as , StyleBox[Show, InlineInput], .}], Text],Cell[CellGroupData[{Cell[BoxData[ (Show[p])], Input],Cell[GraphicsData[PostScript, <%!%%Creator: Mathematica%%AspectRatio: .61803 MathPictureStart/Mabs {Mgmatrix idtransformMtmatrix dtransform} bind def/Mabsadd { Mabs3 -1 roll add3 1 roll addexch } bind def%% Graphics%%IncludeResource: font Courier%%IncludeFont: Courier/Courier findfont 10 scalefont setfont% Scaling calculations0.0238095 0.952381 0.0147151 0.588604 [[ 0 0 0 0 ][ 1 .61803 0 0 ]] MathScale% Start of Graphics1 setlinecap1 setlinejoinnewpath0 0 m1 0 L1 .61803 L0 .61803 Lclosepathclipnewpath0 g.5 Mabswid[ ] 0 setdash.02381 .01472 m.97619 .60332 Ls% End of GraphicsMathPictureEnd>], Graphics, ImageSize->{288, 177.938}, ImageMargins->{{43, 0}, {0, 0}}, ImageRegion->{{0, 1}, {0, 1}},CF5dJ6E]HGAYHf4PAg9QL6QYHgmoo`00Yoo`00=Woo00< 007ooOol0igoo000gOol2003WOol003Uoo`800>Eoo`00>goo00< 007ooOol0hWoo000lOol2003ROol003ioo`03001oogoo0=moo`00?goo 0P00ggoo0011Ool2003MOol004=oo`03001oogoo0=Yoo` 00A7oo0P00fWoo0016Ool00`00Oomoo`3GOol004Moo`800=Moo` 00BGoo0P00eGoo001;Ool00`00Oomoo`3BOol004aoo`800=9oo` 00CWoo0P00d7oo001@Ool00`00Oomoo`3=Ool0055oo`800Ool0091oo`8008ioo` 00TWoo0P00S7oo002DOol00`00Oomoo`29Ool009Eoo`8008Uoo`00Ugoo00< 007ooOol0QWoo002HOol20026Ool009Yoo`8008Aoo`00W7oo00< 007ooOol0PGoo002MOol20021Ool009moo`8007moo`00XGoo00< 007ooOol0O7oo002ROol2001lOol00:Aoo`03001oogoo07Uoo`00YGoo0P00 NGoo002WOol2001gOol00:Uoo`03001oogoo07Aoo`00ZWoo0P00M7oo002/ Ool00`00Oomoo`1aOol00:eoo`80075oo`00[goo0P00Kgoo002aOol00` 00Oomoo`1/Ool00;9oo`8006aoo`00]7oo0P00JWoo002fOol00`00Oomoo` 1WOol00;Moo`8006Moo`00^Goo00<007ooOol0I7oo002jOol2001TOol00; aoo`80069oo`00_Woo00<007ooOol0Ggoo002oOol2001OOol00<5oo` 8005eoo`00`goo00<007ooOol0FWoo0034Ool2001JOol00Ool00`00Oomoo`1?Ool00=oo`8003]oo`00iGoo00< 007ooOol0>7oo003VOol2000hOol00>Qoo`03001oogoo03Eoo` 00jGoo0P00=Goo003[Ool2000cOol00>eoo`03001oogoo031oo` 00kWoo0P00<7oo003`Ool00`00Oomoo`0]Ool00?5oo`8002eoo` 00lgoo0P00:goo003eOol00`00Oomoo`0XOol00?Ioo`8002Qoo` 00n7oo0P009Woo003jOol00`00Oomoo`0SOol00?]oo`8002=oo`00oGoo00< 007ooOol087oo003nOol2000POol00?moo`5oo`8001ioo`00ogoo0goo00< 007ooOol06goo003oOol4Ool2000KOol00?moo`Ioo`8001Uoo` 00ogoo27oo00<007ooOol05Woo003oOol9Ool2000FOol00?moo`]oo`03 001oogoo01=oo`00ogoo37oo0P004goo003oOol>Ool2000AOol00?mooa1oo `03001oogoo00ioo`00ogoo4Goo0P003Woo003oOolCOol00`00Oomoo`0; Ool00?mooaAoo`8000]oo`00ogoo5Woo0P002Goo003oOolHOol00` 00Oomoo`06Ool00?moob5oo`00ogoo8Goo003oOolQOol00?moob5oo`00 >],0.00366761, 0.00593432}}],Cell[BoxData[ TagBox[([SkeletonIndicator] Graphics [SkeletonIndicator]), False, Editable->False]], Output]}, Open ]],Cell[TextData[{ StyleBox[Mathematica, FontSlant->Italic], can write an XML representation of a , StyleBox[Mathematica, FontSlant->Italic], graphics expression into a string with , StyleBox[ExportString, InlineInput], and into a file with , StyleBox[Export, InlineInput], .}], Text],Cell[CellGroupData[{Cell[BoxData[ (str = ExportString[p, ])], Input],Cell[BoxData[ (n nn n n n)], Output]}, Open ]],Cell[TextData[{ A string of XML can be read back into , StyleBox[Mathematica, FontSlant->Italic], with the command , StyleBox[ImportString, InlineInput], with a format of , StyleBox[XML, InlineInput], . This returns a symbolic XML expression that is an isomorphic representation of the original XML. The symbolic XML version of the XML can be worked with by standard , StyleBox[Mathematica, FontSlant->Italic], programming techniques. This is demonstrated in the , ButtonBox[next section, ButtonData:>t:1, ButtonStyle->Hyperlink], .}], Text],Cell[CellGroupData[{Cell[BoxData[ (ImportString[str, ])], Input],Cell[BoxData[ ((XMLObject[ Encoding [Rule] UTF-8], (XMLObject[Doctype])[svg, Public [Rule] -//W3C//DTD SVG 1.0//EN, System [Rule] http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd]}, XMLElement[ svg, {{http://www.w3.org/2000/xmlns/, xmlns} [Rule] http://www.w3.org/2000/svg, width [Rule] 288.0pt, height [Rule] 177.994pt, viewBox [Rule] -0.025 -0.0154508 1.05 0.648936, preserveAspectRatio [Rule] xMidYMid meet}, {XMLElement[ g, {transform [Rule] scale(1, -1) translate(0,-0.618034), style [Rule] fill:black; font-family:'Courier New', Courier, Symbol, monospace; font-size:0.021875pt; stroke:black; stroke-width:0.000911458pt}, {XMLElement[line, {fill [Rule] none, x1 [Rule] 0.0, y1 [Rule] 0.0, x2 [Rule] 1.0, y2 [Rule] 0.618034}, {}]}]}], {}, Valid [Rule] True])], Output]}, Open ]],Cell[TextData[{ The command , StyleBox[XML`SVG`GraphicsToSymbolicSVG, InlineInput], goes directly from a , StyleBox[Mathematica, FontSlant->Italic], graphics expression directly to the symbolic XML representation of the SVG.}], Text],Cell[CellGroupData[{Cell[BoxData[ (XML`SVG`GraphicsToSymbolicSVG[p])], Input],Cell[BoxData[ ((XMLObject[ Encoding [Rule] UTF-8], (XMLObject[Doctype])[svg, Public [Rule] -//W3C//DTD SVG 1.0//EN, System [Rule] http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd]}, XMLElement[ svg, {xmlns [Rule] http://www.w3.org/2000/svg, width [Rule] 288.0pt, height [Rule] 177.994pt, viewBox [Rule] -0.025 -0.0154508 1.05 0.648936, preserveAspectRatio [Rule] xMidYMid meet}, {XMLElement[ g, {transform [Rule] scale(1, -1) translate(0,-0.618034), style [Rule] fill:black; font-family:'Courier New', Courier, Symbol, monospace; font-size:0.021875pt; stroke:black; stroke-width:0.000911458pt}, {XMLElement[line, {fill [Rule] none, x1 [Rule] 0.0, y1 [Rule] 0.0, x2 [Rule] 1.0, y2 [Rule] 0.618034}, {}]}]}], {}])], Output]}, Open ]]}, Open ]],Cell[CellGroupData[{Cell[Generating an SVG Animation, Section, CellTags->t:1],Cell[TextData[{ StyleBox[Mathematica, FontSlant->Italic], can solve a differential equation:}], Text],Cell[CellGroupData[{Cell[BoxData[ (sol = NDSolve[{ (x'')[t] + 0.15 (x')[t] - x[t] + x[t]^3 [Equal] 5 Cos[t], [IndentingNewLine]x[0] [Equal] 1, (x')[0] [Equal] 2}, x, {t, 0, 20}])], Input],Cell[BoxData[ RowBox[{{, RowBox[{{, RowBox[{x, [Rule], TagBox[(InterpolatingFunction[{{0.`, 20.`}}, <>]), False, Editable->False]}], }}], }}]], Output]}, Open ]],Cell[and then the solution can be plotted., Text],Cell[CellGroupData[{Cell[BoxData[ ((p = ParametricPlot[ Evaluate[{x[t], (x')[t]} /. sol], {t, 0, 20}];))], Input],Cell[GraphicsData[PostScript, <%!%%Creator: Mathematica%%AspectRatio: .61803 MathPictureStart/Mabs {Mgmatrix idtransformMtmatrix dtransform} bind def/Mabsadd { Mabs3 -1 roll add3 1 roll addexch } bind def%% Graphics%%IncludeResource: font Courier%%IncludeFont: Courier/Courier findfont 10 scalefont setfont% Scaling calculations0.477803 0.15697 0.306151 0.0573087 [[.00689 .29365 -6 -9 ][.00689 .29365 6 0 ][.16386 .29365 -6 -9 ][.16386 .29365 6 0 ][.32083 .29365 -6 -9 ][.32083 .29365 6 0 ][.63477 .29365 -3 -9 ][.63477 .29365 3 0 ][.79174 .29365 -3 -9 ][.79174 .29365 3 0 ][.94871 .29365 -3 -9 ][.94871 .29365 3 0 ][.4653 .07692 -12 -4.5 ][.4653 .07692 0 4.5 ][.4653 .19153 -12 -4.5 ][.4653 .19153 0 4.5 ][.4653 .42077 -6 -4.5 ][.4653 .42077 0 4.5 ][.4653 .53539 -6 -4.5 ][.4653 .53539 0 4.5 ][ 0 0 0 0 ][ 1 .61803 0 0 ]] MathScale% Start of Graphics1 setlinecap1 setlinejoinnewpath0 g.25 Mabswid[ ] 0 setdash.00689 .30615 m.00689 .3124 Ls[(-3)] .00689 .29365 0 1 Mshowa.16386 .30615 m.16386 .3124 Ls[(-2)] .16386 .29365 0 1 Mshowa.32083 .30615 m.32083 .3124 Ls[(-1)] .32083 .29365 0 1 Mshowa.63477 .30615 m.63477 .3124 Ls[(1)] .63477 .29365 0 1 Mshowa.79174 .30615 m.79174 .3124 Ls[(2)] .79174 .29365 0 1 Mshowa.94871 .30615 m.94871 .3124 Ls[(3)] .94871 .29365 0 1 Mshowa.125 Mabswid.03829 .30615 m.03829 .3099 Ls.06968 .30615 m.06968 .3099 Ls.10108 .30615 m.10108 .3099 Ls.13247 .30615 m.13247 .3099 Ls.19526 .30615 m.19526 .3099 Ls.22665 .30615 m.22665 .3099 Ls.25805 .30615 m.25805 .3099 Ls.28944 .30615 m.28944 .3099 Ls.35223 .30615 m.35223 .3099 Ls.38362 .30615 m.38362 .3099 Ls.41501 .30615 m.41501 .3099 Ls.44641 .30615 m.44641 .3099 Ls.5092 .30615 m.5092 .3099 Ls.54059 .30615 m.54059 .3099 Ls.57198 .30615 m.57198 .3099 Ls.60338 .30615 m.60338 .3099 Ls.66617 .30615 m.66617 .3099 Ls.69756 .30615 m.69756 .3099 Ls.72895 .30615 m.72895 .3099 Ls.76035 .30615 m.76035 .3099 Ls.82314 .30615 m.82314 .3099 Ls.85453 .30615 m.85453 .3099 Ls.88592 .30615 m.88592 .3099 Ls.91732 .30615 m.91732 .3099 Ls.98011 .30615 m.98011 .3099 Ls.25 Mabswid0 .30615 m1 .30615 Ls.4778 .07692 m.48405 .07692 Ls[(-4)] .4653 .07692 1 0 Mshowa.4778 .19153 m.48405 .19153 Ls[(-2)] .4653 .19153 1 0 Mshowa.4778 .42077 m.48405 .42077 Ls[(2)] .4653 .42077 1 0 Mshowa.4778 .53539 m.48405 .53539 Ls[(4)] .4653 .53539 1 0 Mshowa.125 Mabswid.4778 .10557 m.48155 .10557 Ls.4778 .13423 m.48155 .13423 Ls.4778 .16288 m.48155 .16288 Ls.4778 .22019 m.48155 .22019 Ls.4778 .24884 m.48155 .24884 Ls.4778 .2775 m.48155 .2775 Ls.4778 .33481 m.48155 .33481 Ls.4778 .36346 m.48155 .36346 Ls.4778 .39211 m.48155 .39211 Ls.4778 .44942 m.48155 .44942 Ls.4778 .47808 m.48155 .47808 Ls.4778 .50673 m.48155 .50673 Ls.4778 .04826 m.48155 .04826 Ls.4778 .01961 m.48155 .01961 Ls.4778 .56404 m.48155 .56404 Ls.4778 .59269 m.48155 .59269 Ls.25 Mabswid.4778 0 m.4778 .61803 Ls0 0 m1 0 L1 .61803 L0 .61803 Lclosepathclipnewpath.5 Mabswid.63477 .42077 m.65038 .43313 L.66878 .44539 L.68599 .45489 L.70585 .46366 L.7185 .46803 L.73045 .47128 L.74207 .4736 L.75453 .47509 L.76573 .4755 L.77622 .47503 L.78766 .47348 L.79981 .47051 L.81209 .46593 L.82312 .46025 L.83472 .45238 L.84633 .44206 L.85653 .43038 L.86525 .41779 L.87232 .40508 L.87883 .39045 L.88384 .37607 L.88824 .35938 L.89118 .34355 L.89299 .32834 L.89392 .31008 L.89363 .29332 L.89194 .27411 L.88902 .25628 L.88482 .23893 L.87977 .22338 L.87306 .2073 L.86455 .19131 L.85491 .17697 L.8436 .16361 L.833 .15354 L.82092 .14431 L.80895 .13702 L.79765 .13152 L.78596 .12703 L.77468 .12368 L.76129 .12076 L.74879 .11894 L.73496 .11779 L.72796 .11751 L.72025 .11741 L.71264 .1175 L.70435 .1178 L.69654 .11826 L.68931 .11881 LMistroke.67573 .12013 L.66139 .12186 L.60063 .13087 L.57204 .13483 L.55824 .13642 L.54567 .13763 L.53426 .1385 L.52229 .13916 L.5103 .13954 L.50351 .13962 L.49719 .13961 L.48504 .13935 L.47891 .13909 L.47213 .13872 L.46011 .13783 L.44878 .13673 L.42293 .13332 L.39442 .12841 L.34361 .11798 L.31465 .11204 L.28696 .10706 L.27369 .10509 L.26106 .10354 L.2464 .10224 L.23303 .10159 L.21814 .10159 L.20446 .10237 L.18953 .1042 L.18207 .10556 L.17394 .10741 L.16083 .11131 L.14913 .11587 L.13601 .12241 L.12404 .12994 L.10417 .14661 L.0939 .15793 L.08509 .16961 L.07634 .18363 L.06819 .19973 L.0621 .21464 L.05663 .23146 L.052 .25043 L.04892 .26864 L.04763 .27996 L.04684 .29071 L.04645 .31085 L.0473 .32841 L.0494 .34662 L.05213 .36166 L.05611 .37753 LMistroke.06146 .39359 L.06837 .40956 L.08357 .43449 L.09417 .44687 L.10481 .45651 L.11722 .46505 L.12381 .46862 L.13109 .47186 L.13818 .4744 L.14478 .47626 L.15115 .47762 L.15793 .47864 L.16975 .47944 L.18273 .479 L.19546 .47735 L.20691 .47492 L.2199 .47112 L.23188 .46668 L.25229 .45715 L.27292 .44495 L.30794 .4177 L.33361 .39052 L.34441 .37598 L.35359 .36093 L.35751 .35318 L.36113 .34485 L.36364 .33796 L.3658 .33062 L.36676 .32664 L.36749 .32301 L.36804 .31964 L.36852 .31599 L.36899 .30975 L.36901 .30331 L.36882 .29972 L.36851 .29649 L.368 .29282 L.36736 .2894 L.36589 .28346 L.36378 .27721 L.35875 .26655 L.35176 .2561 L.34373 .24715 L.33538 .23988 L.32603 .23342 L.31487 .22747 L.30893 .22496 L.30238 .22266 L.29659 .22101 L.29019 .21961 LMistroke.28371 .21863 L.27768 .21811 L.2719 .21798 L.26577 .21824 L.26032 .21884 L.25526 .21973 L.24977 .22108 L.24398 .22297 L.23747 .22574 L.23165 .22888 L.22505 .23333 L.21943 .23804 L.21012 .24842 L.2057 .255 L.20205 .26173 L.19918 .26828 L.19666 .27559 L.19495 .28213 L.19354 .28958 L.19262 .29787 L.19237 .30261 L.19232 .307 L.1927 .31563 L.19365 .32391 L.19507 .33169 L.19717 .34008 L.20246 .35511 L.2064 .36364 L.21122 .37243 L.22152 .38753 L.23448 .40233 L.24842 .4151 L.28604 .44064 L.32474 .45991 L.36425 .47637 L.46796 .51632 L.5932 .56481 L.62766 .57685 L.66638 .58859 L.68927 .59431 L.71056 .59859 L.73223 .60171 L.75298 .60332 L.77522 .60327 L.78762 .60232 L.7988 .60083 L.82038 .59603 L.84028 .58898 L.85136 .58377 L.86282 .57728 LMistroke.88256 .56298 L.90246 .54359 L.92228 .51748 L.93718 .49136 L.94894 .46464 L.95463 .44876 L.96012 .43071 L.96814 .39609 L.97324 .36207 L.97602 .32492 L.97619 .29292 L.97404 .25795 L.96945 .22373 L.96307 .19333 L.95386 .16205 L.94166 .1316 L.92645 .10325 L.91016 .08025 L.89416 .06278 L.87562 .04723 L.85863 .03643 L.83926 .02733 L.81845 .02068 L.79864 .01681 L.77994 .01502 L.7628 .01472 L.74305 .01573 L.72442 .01782 L.70472 .02104 L.68325 .02551 L.64093 .03651 L.56944 .05825 L.49726 .0793 L.46033 .08833 L.42715 .09512 L.37011 .10405 L.31008 .11165 L.28463 .11534 L.26107 .11964 L.23467 .1261 L.21159 .1339 L.18738 .14523 L.16377 .16082 L.14573 .17727 L.1286 .19873 L.12043 .21218 L.11394 .22528 L.10769 .24118 L.10304 .2569 L.09991 .27172 LMistroke.098 .28562 L.09734 .29364 L.09702 .30088 L.09697 .30918 L.09725 .31692 L.0984 .3298 L.10057 .34313 L.10348 .35513 L.10683 .3655 L.11154 .37685 L.11755 .38811 L.13055 .40538 L.13786 .41235 L.14645 .41876 L.15589 .42403 L.16035 .42596 L.1651 .42768 L.1739 .43 L.18207 .43124 L.19093 .43169 L.19595 .43155 L.20061 .43118 L.20889 .42997 L.21774 .42792 L.22594 .42533 L.23332 .42243 L.24676 .41574 L.26002 .40719 L.28372 .38584 L.29455 .37216 L.3028 .3587 L.30633 .35154 L.30951 .34381 L.31178 .33706 L.31373 .32971 L.31467 .32518 L.31535 .32101 L.31585 .31701 L.31621 .3128 L.31642 .30548 L.31631 .30134 L.31606 .29749 L.31514 .28992 L.31376 .28282 L.31209 .27649 L.30984 .2697 L.30313 .25483 L.29495 .24169 L.27645 .22073 L.26374 .21033 LMistroke.2506 .2019 L.24308 .19798 L.23569 .19472 L.2288 .19219 L.22129 .18997 L.21304 .18819 L.20527 .18714 L.20049 .18681 L.19598 .18672 L.18755 .18717 L.17966 .18835 L.1713 .19048 L.16358 .19334 L.15673 .19669 L.149 .20152 L.14103 .20791 L.12799 .22247 L.12235 .23104 L.11687 .24147 L.11206 .25334 L.10846 .26526 L.10595 .27693 L.10439 .288 L.10353 .30046 L.1036 .31376 L.1045 .32546 L.10598 .33602 L.10849 .34803 L.11161 .3591 L.11894 .37784 L.12401 .38775 L.12926 .3964 L.14192 .41287 L.15811 .42812 L.16701 .43462 L.17707 .44077 L.1963 .44972 L.20747 .4536 L.21782 .4565 L.22999 .4592 L.24162 .46118 L.25255 .46259 L.26267 .46357 L.27384 .46437 L.28568 .46496 L.29771 .46534 L.30446 .46549 L.31062 .4656 L.33394 .4659 L.347 .46608 LMistroke.35439 .46623 L.36123 .4664 L.3738 .46683 L.38016 .46711 L.38718 .46749 L.39899 .46827 L.41148 .46933 L.43405 .47192 L.45882 .47578 L.48665 .48137 L.59226 .5106 L.6228 .51958 L.65734 .5288 L.67366 .53257 L.6912 .53606 L.70637 .5385 L.72321 .54046 L.73965 .5415 L.7547 .54156 L.77204 .54041 L.78836 .53794 L.8032 .53433 L.81671 .52973 L.83117 .52319 L.84602 .51441 L.86254 .50162 L.8767 .48741 L.89091 .46912 L.90412 .4469 L.91398 .42525 L.92163 .40342 L.92818 .37794 L.93098 .36312 L.93295 .34938 L.93518 .32343 L.93553 .29934 L.93405 .27316 L.93257 .2602 L.93038 .24621 L.92544 .22364 L.91844 .20085 L.91033 .18105 L.90174 .16456 L.89063 .1477 L.87909 .13395 L.86783 .12329 L.85527 .11392 L.84091 .10585 L.82724 .10033 L.81219 .09631 LMistroke.80354 .09485 L.79542 .094 L.78094 .0936 L.76724 .09443 L.75501 .09607 L.74185 .0987 L.72776 .10243 L.71311 .10725 L.68776 .11762 L.63666 .14562 L.59649 .17388 L.56147 .20358 L.53286 .23297 L.51587 .25449 L.50375 .27425 L.49937 .28373 L.49666 .29146 L.49574 .2949 L.49536 .29662 L.49501 .2984 L.49457 .30149 L.49435 .30417 L.4943 .30665 L.49439 .30876 L.49465 .31103 L.49504 .31302 L.49551 .31471 L.49604 .31615 L.4967 .31759 L.4975 .31897 L.49848 .3203 L.49963 .32152 L.50081 .32246 L.50194 .32315 L.503 .32364 L.50419 .32401 L.50546 .32422 L.50664 .32425 L.50796 .32411 L.50862 .32396 L.50933 .32375 L.51058 .32322 L.5117 .32257 L.51296 .32159 L.51404 .32051 L.51512 .31911 L.51613 .3174 L.51685 .31582 L.51749 .31396 L.51796 .31204 LMistroke.51827 .31015 L.51848 .30777 L.51851 .30634 L.51849 .30498 L.51832 .30234 L.51793 .29938 L.51739 .29658 L.51673 .2939 L.51462 .28744 L.51186 .28093 L.50845 .27429 L.49777 .25784 L.48078 .23743 L.43207 .19295 L.3479 .13631 L.29286 .10916 L.27643 .10271 L.25857 .09667 L.24274 .09226 L.23391 .09021 L.22549 .08855 L.20891 .08617 L.19372 .08515 L.17944 .0853 L.16401 .08684 L.15597 .08826 L.1472 .09035 L.13813 .09316 L.12977 .09637 L.11518 .10364 L.10014 .11369 L.08586 .12626 L.07383 .13977 L.0612 .15785 L.05072 .17718 L.04237 .19695 L.03596 .2165 L.03041 .23923 L.02634 .26432 L.02416 .29041 L.02381 .30518 L.02403 .31865 L.02595 .34457 L.02953 .36847 L.03229 .38154 L.03579 .39501 L.04347 .41794 L.0536 .4405 L.06681 .46249 L.07879 .47781 LMistroke.09252 .49158 L.105 .50143 L.11933 .51025 L.13544 .51759 L.14468 .52076 L.15318 .52309 L.1612 .52482 L.16995 .52624 L.18593 .52767 L.20087 .52783 L.21726 .52686 L.22548 .52598 L.23426 .52478 L.24999 .52201 L.27979 .51496 L.30606 .50728 L.40373 .47409 L.45045 .46018 L.47204 .45509 L.49129 .45146 L.50207 .44985 L.51375 .44843 L.52539 .44738 L.53171 .44696 L.53758 .44665 L.54802 .44632 L.55751 .44624 L.56276 .44628 L.56846 .44639 L.57884 .44674 L.58854 .44724 L.59928 .44794 L.62118 .4497 L.64181 .45152 L.66121 .45308 L.67138 .45374 L.68227 .45426 L.68851 .45446 L.69439 .45456 L.70539 .45449 L.71591 .45408 L.72556 .45334 L.73607 .45207 L.74707 .45016 L.75614 .44805 L.76569 .44525 L.78238 .43859 L.79211 .43346 L.80096 .42781 L.81634 .41513 LMistroke.83093 .3983 L.83732 .38867 L.84353 .37726 L.84805 .367 L.85213 .35545 L.85518 .34419 L.85728 .33365 L.85888 .32111 L.85952 .30943 L.85951 .30276 L.85928 .29676 L.85874 .28991 L.85796 .28355 L.85696 .27749 L.85565 .27121 L.85267 .26042 L.8486 .24957 L.84316 .23868 L.83783 .23039 L.83237 .22354 L.8253 .21649 L.81843 .21116 L.81154 .20702 L.80481 .20394 L.79751 .20156 L.79334 .20059 L.78948 .19993 L.78264 .19931 L.77625 .1993 L.76926 .19989 L.76184 .20119 L.75417 .20322 L.74708 .20574 L.73433 .2118 L.72123 .22027 L.7088 .23082 L.69954 .24076 L.69089 .25242 L.68354 .26542 L.68031 .27286 L.67792 .27969 L.67626 .28571 L.67494 .29225 L.67446 .29553 L.6741 .29901 L.67379 .30522 L.67389 .3103 L.67437 .31579 L.67526 .32139 L.67644 .3265 LMistroke.67786 .33115 L.6794 .33527 L.68371 .34407 L.68952 .35266 L.6971 .36088 L.70531 .36736 L.70924 .3698 L.71365 .3721 L.71785 .3739 L.72179 .37527 L.72563 .37631 L.72972 .3771 L.73427 .37761 L.73852 .37774 L.74317 .37747 L.74812 .3767 L.75285 .37547 L.75786 .37359 L.76245 .37128 L.76652 .36869 L.77373 .3626 L.77707 .35895 L.78047 .35449 LMfstroke% End of GraphicsMathPictureEnd>], Graphics, ImageSize->{288, 177.938}, ImageMargins->{{43, 0}, {0, 0}}, ImageRegion->{{0, 1}, {0, 1}},CF5dJ6E]HGAYHf4PAg9QL6QYHgOol< 000POol00`00Oomoo`0EOol002Qoo`80025oo`@002Yoo`H000aoo` 03001oogoo04Yoo`@000aoo`@001eoo`03001oogoo01Aoo` 009Woo0P0067oo1`0027oo0P0087oo20004Woo00<007ooOol0AWoo1000 57oo0`006Woo00<007ooOol057oo000TOol2000AOol90007Ool= 000DOol9000JOol20013Ool4000KOol2000IOol00`00Oomoo`0COol002= oo`03001oogoo00ioo`<001aoo`H000Moo`P002=oo`03001oogoo03ioo`@ 0025oo`8001Moo`03001oogoo01=oo`008Goo0P003Goo10008goo2@00: goo00<007ooOol0?7oo0P009goo0P005Woo00<007ooOol04Woo000POol00 `00Oomoo`0;Ool2000QOol700000goo00000004Ool4000XOol00`00Oomoo `0jOol2000[Ool2000DOol00`00Oomoo`0BOol001moo`03001oogoo00Yoo `8001ioo`D000Yoo`8000Ioo`D002=oo`03001oogoo03Qooa<001ioo`8001 =oo`03001oogoo015oo` 007Goo0P002goo0P0077oo10004Goo0P002Goo10007goo00<007ooOol0; goo2@004goo100077oo00<007ooOol047oo00<007ooOol04Goo000LOol00 `00Oomoo`09Ool2000KOol3000GOol2000;Ool5000JOol00`00Oomoo` 0YOol60005Ool2000IOol4000IOol00`00Oomoo`0@Ool00`00Oomoo`0@ Ool001]oo`03001oogoo00Uoo`03001oogoo01Moo`@001aoo`8000ioo` H001Aoo`03001oogoo02=oo`H000Uoo`8001moo`<001Moo` 03001oogoo00moo`03001oogoo011oo`006Woo00<007ooOol02Goo00< 007ooOol05Woo0P008Woo0P004Woo200037oo00<007ooOol077oo1` 003Woo00<007ooOol08Woo0`005Goo00<007ooOol03goo00< 007ooOol03goo000IOol00`00Oomoo`09Ool00`00Oomoo`0E Ool2000VOol2000HOol60006Ool2000DOol9000COol2000XOol2000DOol00 `00Oomoo`0>Ool00`00Oomoo`0?Ool001Qoo`03001oogoo00Qoo`8001Moo `03001oogoo02Qoo`8001aooa`001Yoo`8002aoo`8001=oo` 03001oogoo00ioo`03001oogoo00ioo`005goo00<007ooOol027oo00< 007ooOol05Goo0P00;Goo00<007ooOol07goo00<007ooOol0:goo0P00< 7oo0P004Woo00<007ooOol03Goo00<007ooOol03Woo000GOol00`00Oomoo `07Ool00`00Oomoo`0EOol00`00Oomoo`0^Ool2000OOol00`00Oomoo` 0ZOol00`00Oomoo`0bOol00`00Oomoo`0@Ool00`00Oomoo`0Ool001Ioo`03001oogoo00Moo`03001oogoo01Aoo`8003=oo` 03001oogoo01aoo`03001oogoo02Qoo`8003Ioo`03001oogoo011oo` 03001oogoo00aoo`03001oogoo00eoo`005Woo00<007ooOol01Woo00< 007ooOol04goo0P00=Woo0P0077oo00<007ooOol09goo00<007ooOol0= goo00<007ooOol03goo00<007ooOol037oo00<007ooOol03Goo000EOol00 `00Oomoo`06Ool00`00Oomoo`0BOol2000jOol00`00Oomoo`0IOol00` 00Oomoo`0UOol2000kOol00`00Oomoo`0?Ool00`00Oomoo`0Ool00`00Oomoo`04Ool00`00Oomoo` 0EOol2000gOol00`00Ool00002Ool00`00Oomoo`03Ool00`00Oomoo` 0EOol00`00Oomoo`0gOol8000DOol00`00Oomoo`0;Ool00`00Oomoo`0: Ool00`00Oomoo`09Ool000moo`03001oogoo00Aoo`03001oogoo00ioo` 03001oogoo00=oo`8001Yoo`8003Ioo`04001oo`000006Ool00`00Oomoo` 0DOol00`00Oomoo`0dOol40008Ool3000BOol00`00Oomoo`0:Ool00` 00Oomoo`0;Ool00`00Oomoo`08Ool000moo`03001oogoo00Aoo`03001o ogoo00ioo`04001oogooOol2000NOol2000eOol00`00Oomoo`06Ool00` 00Oomoo`0COol00`00Oomoo`0cOol2000?Ool2000AOol00`00Oomoo`0: Ool00`00Oomoo`0:Ool00`00Oomoo`08Ool000moo`03001oogoo00=oo` 03001oogoo00ioo`05001oogooOol0000ROol2000dOol00`00Oomoo` 05Ool00`00Oomoo`0BOol00`00Oomoo`0bOol2000COol2000?Ool00` 00Oomoo`0:Ool00`00Oomoo`0:Ool00`00Oomoo`08Ool000ioo` 03001oogoo00Aoo`03001oogoo00ioo`05001oogooOol0000TOol00` 00Oomoo`0bOol00`00Oomoo`04Ool00`00Oomoo`0AOol00`00Oomoo` 0aOol2000GOol00`00Oomoo`0 Woo00<007ooOol05Goo00<007ooOol04Woo00<007ooOol01goo00< 007ooOol02Goo00<007ooOol02Goo00<007ooOol01Woo000Ool2000JOol00`00Oomoo`0BOol00`00 Oomoo`0Ool00` 00Oomoo`04Ool00`00Oomoo`0>Ool2000KOol00`00Oomoo`0=Ool00` 00Oomoo`0Ool00` 00Ool0000LOol00`00Oomoo`06Ool00`00Oomoo`0=Ool00`00Oomoo` 0YOol00`00Oomoo`1POol00`00Oomoo`09Ool00`00Oomoo`0;Ool00` 00Oomoo`0:Ool00`00Oomoo`08Ool000moo`03001oogoo00Aoo`03001o ogoo00moo`03001oo`0001aoo`03001oogoo00Aoo`03001oogoo00eoo` 03001oogoo02Yoo`03001oogoo05moo`03001oogoo00Yoo`03001oogoo00 ]oo`03001oogoo00Yoo`03001oogoo00Qoo`003goo00<007ooOol01Goo00 <007ooOol03goo0`0077oo00<007ooOol00Woo00<007ooOol03Woo00< 007ooOol0:Woo00<007ooOol0Ggoo00<007ooOol02Goo00< 007ooOol037oo00<007ooOol02Goo00<007ooOol02Goo000?Ool00` 00Oomoo`05Ool00`00Oomoo`0AOol2000LOol01000Ool0000047oo00< 007ooOol0:goo00<007ooOol0GWoo00<007ooOol02Woo00< 007ooOol02goo00<007ooOol02Woo00<007ooOol02Goo000@Ool00` 00Oomoo`05Ool00`00Oomoo`0AOol2000KOol2000AOol00`00Oomoo` 0SOol40005Ool00`00Oomoo`1MOol00`00Oomoo`0:Ool00`00Oomoo`0< Ool00`00Oomoo`0:Ool00`00Oomoo`09Ool0011oo`03001oogoo00Eoo` 03001oogoo019oo`8001Qoo`80009oo`8000ioo`03001oogoo02Aoo` 03001oogoo00Ioo`03001oogoo05aoo`03001oogoo00]oo` 03001oogoo00aoo`03001oogoo00Yoo`03001oogoo00Uoo`0047oo00< 007ooOol01Woo00<007ooOol04Woo0P005Goo0P001Woo00<0 07ooOol02Goo0P00:7oo00<007ooOol01Goo0`00:Goo00<007ooOol0; Woo0P003Goo00<007ooOol037oo00<007ooOol02Woo00< 007ooOol02Woo000AOol00`00Oomoo`05Ool00`00Oomoo`0COol3000A Ool20009Ool00`00Oomoo`07Ool00`00Oomoo`0YOol00`00Oomoo`04Ool00 `00Oomoo`0ZOol2000]Ool00`00Oomoo`0=Ool00`00Oomoo`0Ool00`00Oomoo`0goo0` 006Goo0`003Goo00<007ooOol047oo1000Egoo00<007ooOol047oo00< 007ooOol04Goo000ROol00`00Oomoo`0gOol3000OOol2000;Ool00` 00Oomoo`0DOol4001BOol00`00Oomoo`0@Ool00`00Oomoo`0BOol002=oo` 8003Aoo`<002Aoo`8000Uoo`8001Uoo`@004aoo`8001=oo`03001o ogoo019oo`009Goo0P00;Woo1000:Goo0`001Woo00<007ooOol077oo0` 00Agoo0P0057oo00<007ooOol04goo000WOol2000XOol4000` Ool20004Ool00`00Oomoo`0OOol30013Ool00`00Oomoo`0DOol00` 00Oomoo`0COol002Uoo`80029oo`@003Ioo`<00003Ool007oo02=oo`< 003moo`03001oogoo01Aoo`03001oogoo01Aoo`00:goo0`006goo1000? Goo0`009Woo1000>Goo0P005Woo00<007ooOol05Goo000^Ool8000= Ool60012Ool01000Ool00000:7oo1@007oo10008Goo0`00< Woo002;Ool00`00Oomoo`0lOol6000HOol3000eOol008]oo` 03001oogoo049ooaP003Qoo`00Rgoo00<007ooOol0TWoo002;Ool00` 00Oomoo`2BOol008]oo`03001oogoo099oo`00Rgoo00< 007ooOol0TWoo003oOolQOol00001>],0.0225154, 0.0616701}}]}, Open ]],Cell[, Text],Cell[BoxData[ ((( )(xml = XML`SVG`GraphicsToSymbolicSVG[p];)))], InputOnly],Cell[TextData[{ The SVG is larger than the , StyleBox[Mathematica, FontSlant->Italic], graphics language representation, }], Text],Cell[CellGroupData[{Cell[BoxData[ (ByteCount /@ {ExportString[xml, ], ToString[p, InputForm], ExportString[p, ]})], Input],Cell[BoxData[ ({20832, 27104, 13936})], Output]}, Open ]],Cell[TextData[{ Find the XML fragment that holds the line for the solution, it will be the first instance of , StyleBox[ , InlineInput], .}], Text],Cell[BoxData[ ((( )(pts = <> n First[ Cases[ xml, n XMLElement[, { -> _, -> x_}, _] -> x, Infinity]];)))], InputOnly],Cell[TextData[{ Generate a new fragment of symbolic XML that holds an SVG animation, this has the form n, StyleBox[ , InlineInput], .}], Text],Cell[BoxData[ ((( )(newElem = XMLElement[, n { -> <0>, -> <0>, -> <.1>, -> , [IndentingNewLine]tt -> , -> <0.01>}, n {XMLElement[ , [IndentingNewLine] { -> <6s>, -> , [IndentingNewLine] -> , -> pts}, {}]}];)))], InputOnly],Cell[Now we add this new fragment back into the original SVG, Text],Cell[BoxData[ ((newXML = xml /. x : XMLElement[, ___] -> Sequence[x, newElem] ;))], InputOnly],Cell[Export the SymbolicXML out to a file, Text],Cell[CellGroupData[{Cell[BoxData[ (((Export[, newXML, ])( )))], Input],Cell[BoxData[ (file.svg)], Output]}, Open ]],Cell[, Text]}, Open ]]},ScreenRectangle->{{0, 1280}, {0, 934}},WindowSize->{839, 690},WindowMargins->{{Automatic, 146}, {Automatic, 23}},StyleDefinitions -> DemoText.nb](********************************************** *********************the top of the file. The cache data will then be recreated whenyou save this file from within Mathematica.************************************************* ******************)(*CellTagsOutlineCellTagsIndex->{ t:1->{ Cell[12796, 351, 65, 1, 54, Section, CellTags->t:1]} }*)(*CellTagsIndexCellTagsIndex->{ {t:1, 53445, 1649} }*)(*NotebookFileOutlineNotebook[{Cell[1754, 51, 105, 4, 70, Title],Cell[1862, 57, 56, 0, 41, Subtitle],Cell[1921, 59, 82, 3, 76, Subsubtitle],Cell[CellGroupData[{Cell[2028, 66, 31, 0, 54, Section],Cell[2062, 68, 487, 9, 67, Text],Cell[2552, 79, 513, 13, 48, Text]}, Open ]],Cell[CellGroupData[{Cell[3102, 97, 115, 4, 54, Section],Cell[3220, 103, 214, 7, 29, Text],Cell[CellGroupData[{Cell[3459, 114, 71, 1, 40, Input],Cell[3533, 117, 130, 3, 49, Output]}, Open ]],Cell[3678, 123, 172, 5, 30, Text],Cell[CellGroupData[{Cell[3875, 132, 40, 1, 40, Input],Cell[3918, 135, 4217, 90, 194, 661, 42, GraphicsData, PostScript, Graphics],Cell[8138, 227, 130, 3, 49, Output]}, Open ]],Cell[8283, 233, 335, 11, 50, Text],Cell[CellGroupData[{Cell[8643, 248, 65, 1, 40, Input],Cell[8711, 251, 690, 10, 372, Output]}, Open ]],Cell[9416, 264, 623, 18, 68, Text],Cell[CellGroupData[{Cell[10064, 286, 63, 1, 40, Input],Cell[10130, 289, 1159, 20, 201, Output]}, Open ]],Cell[11304, 312, 268, 8, 49, Text],Cell[CellGroupData[{Cell[11597, 324, 65, 1, 40, Input],Cell[11665, 327, 1082, 18, 182, Output]}, Open ]]}, Open ]],Cell[CellGroupData[{Cell[12796, 351, 65, 1, 54, Section, CellTags->t:1],Cell[12864, 354, 119, 4, 29, Text],Cell[CellGroupData[{Cell[13008, 362, 221, 4, 60, Input],Cell[13232, 368, 225, 6, 49, Output]}, Open ]],Cell[13472, 377, 53, 0, 29, Text],Cell[CellGroupData[{Cell[13550, 381, 124, 3, 40, Input],Cell[13677, 386, 36505, 1162, 194, 13123, 869, GraphicsData, PostScript, Graphics]}, Open ]],Cell[50197, 1551, 123, 3, 29, Text],Cell[50323, 1556, 103, 2, 48, InputOnly],Cell[50429, 1560, 152, 5, 29, Text],Cell[CellGroupData[{Cell[50606, 1569, 139, 2, 40, Input],Cell[50748, 1573, 55, 1, 49, Output]}, Open ]],Cell[50818, 1577, 198, 5, 30, Text],Cell[51019, 1584, 325, 5, 88, InputOnly],Cell[51347, 1591, 206, 5, 61, Text],Cell[51556, 1598, 697, 10, 148, InputOnly],Cell[52256, 1610, 71, 0, 29, Text],Cell[52330, 1612, 145, 3, 48, InputOnly],Cell[52478, 1617, 52, 0, 29, Text],Cell[CellGroupData[{Cell[52555, 1621, 88, 1, 40, Input],Cell[52646, 1624, 44, 1, 49, Output]}, Open ]],Cell[52705, 1628, 99, 2, 29, Text]}, Open ]]}]*)(****************************************************** *************End of Mathematica Notebook file.********************************************************* **********) ==== >What is the difference between using Fit and Interpolation?>f[x_]=Fit[data, {1,x},x] -or- f[x_]=Interpolation[data][x]There are several differences between the expressions aboveFirst, Interpolation[data][x] isn't correct syntax. It should be Interpolation[data]. Interpolation returns a pure function of data. By default that is a 3rd order polynominal that passes through each of the points specified by the variable data.In contrast, Fit[data,{1,x},x] returns a best fit *line* for the points specified by data. The result is not a pure function but an expression. The result is a least squares fit to the data and will not pass through the points specified unless they lie exactly on a line.The two functions, Interpolation and Fit, are intended for different purposes.Suppose you had a list of data points that were known to be accurate to the precesion specified and wanted to estimate the value of the unknown function at an intermediate point. For this you would use interpolation since you want the result to pass through each of the data points you started with.Now suppose you had a list of data points where each data point you have is really the sum of a true value and a random error. The best result would ideally subtract out the error and yeild the true values. So, you would definitely not want the result to pass through the points with error. For this problem you would use Fit. ==== Dear MathGroup,I am working on an application where I define a number of graphical objects,which can then be used like graphical primitives. I also want to definegraphical primitives that will control the color, position and size of someof these objects. The use of color is slightly complicated because the colorthat is set may be used for lines, or in SurfaceColor or in EdgeForm and itmay be lightened or darkened.My basic approach is to store the value of the directives in internalvariables and then the graphical primitives use these values.But it is difficult to make it all behave just like regular Mathematicagraphical directives.1) The list of primitives must be HoldFirst. Premature evaluation will causethe last instance of a programmed directive to be used for all cases.2) The default values of any primitives must be set before the primitivesare evaluated else whatever is left over from the last plot will be used.I can pretty much handle those problems. The last problem is more difficultand is the core of my question.3) Regular graphics directives are nested in the sense that if one is setinside brackets, {directive,... }, then, after exiting the brackets, thedirective reverts to the value existing before the brackets were entered.Is it possible to program that behavior?Here is an example. It could be done with regular Mathematica directives,but it was picked to be a simple example. In my actual cases I have to useprogramming. The extra graphical primitive is a ColoredLine. The color to beLineColor. The value is stored in currentcolor.Needs[Graphics`Colors`]currentcolor = Black;ColoredLine[start_, end_] := {currentcolor, Line[{start, end}]}LineColor[color_] := (currentcolor = color; Sequence[]) Show[Graphics[ {LineColor[Black], Sequence @@ primitives}], opts]In the following use everything works. {ColoredLine[{0, 0}, {1, 0}], LineColor[Red], ColoredLine[{0, 1}, {1, 1}], LineColor[Blue], Coloredline[{0, 2}, {1, 2}]}, Background -> Linen, ImageSize -> 400];But if I use nesting it, of course, doesn't work like regular Mathematicadirectives. The color does not revert to Black. {ColoredLine[{0, 0}, {1, 0}], {LineColor[Red], ColoredLine[{0, 1}, {1, 1}]}, Coloredline[{0, 2}, {1, 2}]}, Background -> Linen, ImageSize -> 400];It appears that I need to somehow implement a recursive evaluation of theprimitives list. Any ideas on how I could do that.David Parkdjmp@earthlink.nethttp://home.earthlink.net/~djmp/ ==== I have a complex-valued function f(z).If z = x + I y, suppose f(z) has a finite number of simple zerosin the rectangle a < x < b, c < y < d. (and no poles).I can start FindRoot somewhere and it will likely find a root.But, my question is:is there a (best?) systematic way to use Mathematica to findall the roots in the region?