HP-299 === Subject: Re: question on Plot and Show plus Axis Labels I got it working now. I used MultipleListPlot for the problem, with Frames -> True. I think if I dont use Frames, rotating the y-axis label is difficult. Here is a sample of my code. MultipleListPlot[{y0, y, y1, y2}, PlotJoined -> {True, True, True, True}, Frame -> True, FrameLabel -> {FontForm[XaxisLabelhere, {Courier-Bold, 14}], FontForm[YaxisLabelhere, {Courier-Bold, 14}]}, PlotStyle -> {{Thickness[0.005], GrayLevel[0.75]}, {Thickness[0.005], GrayLevel[0]}, {GrayLevel[0.75], Dashing[{0.009}]}, {GrayLevel[0], Dashing[{0.009}]}}, PlotLegend -> {Analytical 1, Analytical 2, Test 1, Test 2}, ImageSize -> 500, PlotRange -> All, RotateLabel -> True, SymbolShape -> {None, None, None, None}, LegendPosition -> {-0.7, -0.45}, LegendSize -> {0.7, 0.3}] Bob, I see that Plot is working if we directly substitute the functions inside, as well as to some functions with a rule, and in some cases, we need Evaluate[] for the same. But somehow, when I used Plot[] for my dataset, its giving me error saying 'not a machine-size real number at x=1.0000+'. The command MultipleListPlot works great. For example, see the below code. n = 5; x = Table[i, {i, -n, n}]; y1[x_] := x; y2[x_] := x^2; y3[x_] := x^3; p1 = Table[y1[x[[i]]], {i, 1, 2*n + 1}]; p2 = Table[y2[x[[i]]], {i, 1, 2*n + 1}]; p3 = Table[y3[x[[i]]], {i, 1, 2*n + 1}]; Plot[{y1[x], y2[x], y3[x]}, {x, -n, n}]; Plot[p1, {x, -n, n}]; Plot works fine when we directly substitute the functions, but not when we place the table of data already generated. Placing Evaluate[] or //N in Table doesnt help too. Gopinath Venkatesan Graduate Student University of Oklahoma === Subject: How to remove Dot? Consider the following code: {1, 2}.{4, 5} Dot[{1, 2}, {4, 5}] Unprotect[System`Dot]; Remove[System`Dot]; {1, 2}.{4, 5} Dot[{1, 2}, {4, 5}] On my system (Mathematica 5.2) the symbol Dot is extensively removed, however the . operator still works and cannot be suppressed to make a vector product. How should I solve this situation? Furthermore, entering [Dot] does not result in the . character, as eg. [CenterDot] would do. Is the dot character protected on some higher level? Istvan Zachar === Subject: Re: How to remove Dot? Bytes: 1462 however the . operator still works and cannot be suppressed to make a > vector product. How should I solve this situation? If what you want is multiplying vectors, do you have any good/excellent/superior reasons for not using the standard built-in Mathematica function *Cross* [1]? (By redefining the dot product, or any other built-in functions, you have s very strong likelihood to broke your system.) Cross[a, b] gives the vector cross product of a and b. Jean-Marc [1] http://documents.wolfram.com/mathematica/functions/Cross === Subject: A normalized Series test Adding to the previous post, my 5.0 result with Normal[] is rho=(x+a*I)/(x-a*I); R=Abs[rho]; s=Normal[Series[R,{x,0,4}]]; Print[FullSimplify[s,a>=0&&x>=0]//InputForm]; (3*a^4 - (6*I)*a^3*x - 6*a^2*x^2*(1 + Derivative[2][Abs][-1]) + ( 2*I)*a*x^3*(3 + 6*Derivative[2][ Abs][-1] - 2*Derivative[3][Abs][-1]) + 2*x^4*( 3 + 9*Derivative[2][Abs][-1] - 6*Derivative[ 3][Abs][-1] + Derivative[4][Abs][-1]))/(3*a^4) Verification that indeed R=1: Print[FullSimplify[R,a>=0&&x>=0]//InputForm]; (* Simplify fails *) 1 Print[ComplexExpand[R]//InputForm]; 1 Interestingly, I ran this script on 2.2 (which still runs under Classic). The answer is also messy but the Abs argument is +1. === Subject: Re: Problem with combination NDSolve NIntegrate For comparison, ti[t]/.DSolve[{ti'[t]==ti[t],ti[0]==a},ti[t],t][[1]] a*E^t Integrate[%/.t->5,{a,0,10}] 50*E^5 %//N 7420.66 Clear[trial]; trial[a_?NumberQ]:= NDSolve[{ti'[t]==ti[t],ti[0]==a},ti,{t,0,10}][[1]]; Off[ReplaceAll::reps]; NIntegrate[ (ti[5] /. trial[a]), {a, 0, 10}] 7420.66 Although, in general I recommend that you use NumericQ rather than NumberQ trial[E] trial[E] Clear[trial]; trial[a_?NumericQ]:= NDSolve[{ti'[t]==ti[t],ti[0]==a},ti,{t,0,10}][[1]]; trial[Pi] {ti -> InterpolatingFunction[{{0., 10.}}, <>]} Bob Hanlon > I am using version 5.2 NIntegrate tries to evaluate the integrand symbolically. I try to circumvent this by using ?NumberQ but without success. Please try the following toy example: trial[a_?NumberQ] := NDSolve[{ti'[t] == ti[t] , ti[0] == a} , ti, {t, 0, 10}]; NIntegrate[ (ti[5] /. trial[a]), {a, 0, 10}] Plot[ (ti[5] /. trial[a]), {a, 0, 10}] NIntegrate does not evaluate to a number and throws a warning, while I get a perfect plot from Plot. Does anybody know what to do? > === Subject: Re: Problem with combination NDSolve NIntegrate Clear[trial] trial[a_?NumericQ, where_] := (ti[t] /. NDSolve[{ti'[t] == ti[t], ti[0] == a}, ti, {t, 0, 10}][[1]]) /. t -> where NIntegrate[trial[a, 5], {a, 0, 10}] and Plot[trial[a, 5], {a, 0, 10}] Jens > I am using version 5.2 NIntegrate tries to evaluate the integrand symbolically. I try to circumvent this by using ?NumberQ but without success. Please try the following toy example: trial[a_?NumberQ] := NDSolve[{ti'[t] == ti[t] , ti[0] == a} , ti, {t, 0, 10}]; NIntegrate[ (ti[5] /. trial[a]), {a, 0, 10}] Plot[ (ti[5] /. trial[a]), {a, 0, 10}] NIntegrate does not evaluate to a number and throws a warning, while I get a perfect plot from Plot. Does anybody know what to do? > === Subject: Re: Problem with combination NDSolve NIntegrate Hi , Mamthematica tries to evaluate ti[5] and fails. Put ti[5] inside trial[] and everything works fine: trial[a_?NumberQ] := ti[5] /. NDSolve[{ti'[t] == ti[t], ti[0] == a}, ti, {t, 0, 10}][[1]] Daniel > I am using version 5.2 NIntegrate tries to evaluate the integrand symbolically. I try to circumvent this by using ?NumberQ but without success. Please try the following toy example: trial[a_?NumberQ] := NDSolve[{ti'[t] == ti[t] , ti[0] == a} , ti, {t, 0, 10}]; NIntegrate[ (ti[5] /. trial[a]), {a, 0, 10}] Plot[ (ti[5] /. trial[a]), {a, 0, 10}] NIntegrate does not evaluate to a number and throws a warning, while I get a perfect plot from Plot. Does anybody know what to do? > === Subject: Warning: Actions not found: delete-next-character Every time I run Mathematica 5.2 on SuSe10.1/x86-64 I get a stderr window filled up with: Warning: Actions not found: delete-next-character ... Warning: Actions not found: delete-next-character Is there a fix for this warning? === Subject: Re: Warning: Actions not found: delete-next-character > Every time I run Mathematica 5.2 on SuSe10.1/x86-64 I get a stderr > window filled up with: Warning: Actions not found: delete-next-character > ... > Warning: Actions not found: delete-next-character Is there a fix for this warning? > see here: http://support.wolfram.com/mathematica/systems/linux/intel/deletenext51.html hth, albert === Subject: Re: Warning: Actions not found: delete-next-character > Every time I run Mathematica 5.2 on SuSe10.1/x86-64 I get a stderr > window filled up with: Warning: Actions not found: delete-next-character > .... > Warning: Actions not found: delete-next-character Is there a fix for this warning? > Hi Ted, using one finds directly http://support.wolfram.com/mathematica/systems/linux/intel/deletenext51.html HTH, Peter === Subject: Re: integration > Hello. Consider the following divergent integral Block[{Message}, Integrate[Cos[x]/x, {x, 0, Infinity}]] > Infinity There is a non-integrable singularity at x=0 Series[Cos[x]/x, {x, 0, 3}] > SeriesData[x, 0, {1, 0, -1/2, 0, 1/24}, -1, 4, 1] In the Hadamard sense the integral converges to -EulerGamma. Indeed Integrate[Cos[x]/x, {x, 0, Infinity}, GenerateConditions -> False] > -EulerGamma or Integrate[Cos[x]/x, {x, e, Infinity}, Assumptions -> e > 0] > (Series[#1, {e, 0, 3}] & )[%] > (DeleteCases[#1, (a_)*Log[e], Infinity] & )[%] > (Limit[#1, e -> 0, Direction -> -1] & )[%] -CosIntegral[e] > SeriesData[e, 0, {-EulerGamma - Log[e], 0, 1/4}, 0, 4, 1] > SeriesData[e, 0, {-EulerGamma, 0, 1/4}, 0, 4, 1] > -EulerGamma Next, consider the function f = x^4/(1 + Exp[-x]); The integral does not exist in the Riemann sense. One way to get the > Hadamard finite part is by directly removing the divergent term Integrate[f - x^4, {x, 0, Infinity}] > N[%] > NIntegrate[f - x^4, {x, 0, Infinity}] -((45*Zeta[5])/2) > -23.33087449072582 > -23.330874489932825 So, I wonder if there is any possibility settings like below to ever > work? Integrate[Cos[x]/x - 1/x, {x, 0, Infinity}] > NIntegrate[Cos[x]/x - 1/x, {x, 0, Infinity}] Any ideas? Dimitris Of course not, at least for Integrate. It now has a logarithmic divergent term at infinity. So one would have to remove that singular part instead of the one at the origin. Daniel Lichtblau Wolfram Research === Subject: A Series test Just curious. Could somebody pls run this script on the latest Mathematica user version (I think it's 5.2) under Windows or Unix and report the results: rho=(x+a*I)/(x-a*I); R=Abs[rho]; s=Series[R,{x,0,4}]; Print[FullSimplify[s,a>=0&&x>=0]//InputForm]; My 5.0 answer (Mac G5 under OS 10.4.8) is SeriesData[x, 0, {1, (-2*I)/a, (-2*(1 + Derivative[2][Abs][-1]))/a^2, (((2*I)/3)*(3 + 6*Derivative[2][Abs][-1] - 2*Derivative[3][Abs][-1]))/ a^3, (2*(3 + 9*Derivative[2][Abs][-1] - 6*Derivative[3][Abs][-1] + Derivative[4][Abs][-1]))/(3*a^4)}, 0, 5, 1] The correct answer is 1. (The result with Simplify is more === Subject: Re: A Series test I would like to ask who is able do Mathematica ver 2.x Galois.m from http://library.wolfram.com/infocenter/Articles/2872/ working Galois.nb on Mathematica ver 5.x ARTUR JASINSKI POLAND === Subject: Re: A Series test If you want to try another way to solve your problem, instead of ComplexExpand[], FullSimplify[], etc. you could download the AbsArg package from here: http://library.wolfram.com/infocenter/MathSource/4485/#downloads This package also needs the file NonNegativeQ.m http://library.wolfram.com/infocenter/MathSource/647/ HTH, ~Scout~ > Just curious. Could somebody pls run this script on the > latest Mathematica user version (I think it's 5.2) under > Windows or Unix and report the results: rho=(x+a*I)/(x-a*I); R=Abs[rho]; > s=Series[R,{x,0,4}]; > Print[FullSimplify[s,a>=0&&x>=0]//InputForm]; My 5.0 answer (Mac G5 under OS 10.4.8) is SeriesData[x, 0, {1, (-2*I)/a, (-2*(1 + Derivative[2][Abs][-1]))/a^2, > (((2*I)/3)*(3 + 6*Derivative[2][Abs][-1] - 2*Derivative[3][Abs][-1]))/ > a^3, (2*(3 + 9*Derivative[2][Abs][-1] - 6*Derivative[3][Abs][-1] + > Derivative[4][Abs][-1]))/(3*a^4)}, 0, 5, 1] The correct answer is 1. (The result with Simplify is more > === Subject: Re: A Series test > Just curious. Could somebody pls run this script on the > latest Mathematica user version (I think it's 5.2) under > Windows or Unix and report the results: rho=(x+a*I)/(x-a*I); R=Abs[rho]; > s=Series[R,{x,0,4}]; > Print[FullSimplify[s,a>=0&&x>=0]//InputForm]; My 5.0 answer (Mac G5 under OS 10.4.8) is SeriesData[x, 0, {1, (-2*I)/a, (-2*(1 + Derivative[2][Abs][-1]))/a^2, > (((2*I)/3)*(3 + 6*Derivative[2][Abs][-1] - 2*Derivative[3][Abs][-1]))/ > a^3, (2*(3 + 9*Derivative[2][Abs][-1] - 6*Derivative[3][Abs][-1] + > Derivative[4][Abs][-1]))/(3*a^4)}, 0, 5, 1] The correct answer is 1. (The result with Simplify is more > In[1]:= $Version Out[1]= 5.2 for Microsoft Windows (June 20, 2005) In[2]:= rho = (x + a*I)/(x - a*I); R = Abs[rho]; s = Series[R, {x, 0, 4}]; Print[InputForm[FullSimplify[s, a >= 0 && x >= 0]]]; (a - I*x)/(a + I*x) (* Why not using ComplexExpand? *) In[5]:= ComplexExpand[s] Out[5]= 1 Jean-Marc === Subject: Re: A Series test In[3]:= $Version Out[3]= 5.2 for Linux (June 20, 2005) In[4]:= rho = (x + a*I)/(x - a*I); R = Abs[rho]; s = Series[R, {x, 0, 4}]; Print[InputForm[FullSimplify[s, a >= 0 && x >= 0]]]; InputForm[(a - I*x)/(a + I*x)] No obvious simplification going on (to me). C.O. > Just curious. Could somebody pls run this script on the > latest Mathematica user version (I think it's 5.2) under > Windows or Unix and report the results: rho=(x+a*I)/(x-a*I); R=Abs[rho]; > s=Series[R,{x,0,4}]; > Print[FullSimplify[s,a>=0&&x>=0]//InputForm]; My 5.0 answer (Mac G5 under OS 10.4.8) is SeriesData[x, 0, {1, (-2*I)/a, (-2*(1 + Derivative[2][Abs][-1]))/a^2, > (((2*I)/3)*(3 + 6*Derivative[2][Abs][-1] - 2*Derivative[3][Abs][-1]))/ > a^3, (2*(3 + 9*Derivative[2][Abs][-1] - 6*Derivative[3][Abs][-1] + > Derivative[4][Abs][-1]))/(3*a^4)}, 0, 5, 1] The correct answer is 1. (The result with Simplify is more > -- Curtis Osterhoudt gardyloo@mail.remove_this.wsu.and_this.edu PGP Key ID: 0x088E6D7A Please avoid sending me Word or PowerPoint attachments See http://www.gnu.org/philosophy/no-word-attachments.html === Subject: Re: A Series test > Just curious. Could somebody pls run this script on the > latest Mathematica user version (I think it's 5.2) under > Windows or Unix and report the results: rho=(x+a*I)/(x-a*I); R=Abs[rho]; > s=Series[R,{x,0,4}]; > Print[FullSimplify[s,a>=0&&x>=0]//InputForm]; My 5.0 answer (Mac G5 under OS 10.4.8) is SeriesData[x, 0, {1, (-2*I)/a, (-2*(1 + Derivative[2][Abs][-1]))/a^2, > (((2*I)/3)*(3 + 6*Derivative[2][Abs][-1] - 2*Derivative[3][Abs][-1]))/ > a^3, (2*(3 + 9*Derivative[2][Abs][-1] - 6*Derivative[3][Abs][-1] + > Derivative[4][Abs][-1]))/(3*a^4)}, 0, 5, 1] The correct answer is 1. (The result with Simplify is more > Your code is wrong. The correct one is: rho=(x+a*I)/(x-a*I); R=Abs[rho]; s=Series[ComplexExpand[R],{x,0,4}]; Simplify[s,aÒ0&&xÒ0] 1 Since you refuse to learn even the most basic things about Mathematica, it's no wonder it refuses to work the way you want it to. (However, both the absence of ComplexExpand, about which you have already been told lots of times and the presence of the totally pointless Print command, suggest that your only purpose in writing to this list is to show that you don't care about what others tell you, no matter how often they do so. But then why do you need to demonstrate this point so many times?) Andrzej Kozlowski === Subject: Re: A Series test > Just curious. Could somebody pls run this script on the > latest Mathematica user version (I think it's 5.2) under > Windows or Unix and report the results: rho=(x+a*I)/(x-a*I); R=Abs[rho]; > s=Series[R,{x,0,4}]; > Print[FullSimplify[s,a>=0&&x>=0]//InputForm]; My 5.0 answer (Mac G5 under OS 10.4.8) is SeriesData[x, 0, {1, (-2*I)/a, (-2*(1 + Derivative[2][Abs][-1]))/a^2, > (((2*I)/3)*(3 + 6*Derivative[2][Abs][-1] - 2*Derivative[3][Abs][-1]))/ > a^3, (2*(3 + 9*Derivative[2][Abs][-1] - 6*Derivative[3][Abs][-1] + > Derivative[4][Abs][-1]))/(3*a^4)}, 0, 5, 1] The correct answer is 1. (The result with Simplify is more I'll leave the 5.2 run to others. Here is what happens in the development kernel of Mathematica. rho = (x+a*I)/(x-a*I); absrho = Abs[rho]; In[20]:= InputForm[s0 = Series[absrho, {x,0,4}]] Out[20]//InputForm= Abs[(I*a + x)/((-I)*a + x)] In[21]:= InputForm[s0b = FullSimplify[s0,Assumptions->a>=0&&x>=0]] Out[21]//InputForm= 1 Other possibile routes include using absrho2 = Sqrt[rho*Conjugate[rho]]; or calling ComplexExpand explicitly to get your absolute value. This last will give 1 immediately. Also will do that in version 5.2, if you use Abs rather than Sqrt[rho*Conjugate[rho]]. Daniel Lichtblau Wolfram Research === Subject: Re: A Series test In[8]:= $Version rho = (x + a*I)/(x - a*I) R = Abs[rho] s = Series[R, {x, 0, 4}] FullSimplify[s, a >= 0 && x >= 0] Out[8]= 5.2 for Microsoft Windows (June 20, 2005) Out[9]= (I*a + x)/((-I)*a + x) Out[10]= Abs[(I*a + x)/((-I)*a + x)] Out[11]= Abs[(I*a + x)/((-I)*a + x)] Out[12]= (a - I*x)/(a + I*x) Using ComplexExpand In[18]:= Clear[Global`*] rho = (x + a*I)/(x - a*I) R = ComplexExpand[Abs[rho]] s = Series[R, {x, 0, 4}] FullSimplify[s, a >= 0 && x >= 0] Out[19]= (I*a + x)/((-I)*a + x) Out[20]= 1 Out[21]= 1 Out[22]= 1 But I am not sure if this has any relevance. Dimitris > Just curious. Could somebody pls run this script on the > latest Mathematica user version (I think it's 5.2) under > Windows or Unix and report the results: rho=(x+a*I)/(x-a*I); R=Abs[rho]; > s=Series[R,{x,0,4}]; > Print[FullSimplify[s,a>=0&&x>=0]//InputForm]; My 5.0 answer (Mac G5 under OS 10.4.8) is SeriesData[x, 0, {1, (-2*I)/a, (-2*(1 + Derivative[2][Abs][-1]))/a^2, > (((2*I)/3)*(3 + 6*Derivative[2][Abs][-1] - 2*Derivative[3][Abs][-1]))/ > a^3, (2*(3 + 9*Derivative[2][Abs][-1] - 6*Derivative[3][Abs][-1] + > Derivative[4][Abs][-1]))/(3*a^4)}, 0, 5, 1] The correct answer is 1. (The result with Simplify is more === Subject: normalize a table I want to do something really simple, which is take a table made of pairs and normalize the first number in each pair by dividing by the largest. For instance, I want to transform this list {{1,0.2},{2,0.3},{3,0.4},{4,0.5}} into this one {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} The way i did it is through the chain of commands firsttable={{1,0.2},{2,0.3},{3,0.4},{4,0.5}}; top=Max[Table[firsttable[[i,1]],{i,1,Length[firsttable]}]]; mytable=Do[newtable=ReplacePart[newtable,newtable[[i,1]]/top,{i, 1}],{i,1,Length[firsttable]}] There must be a more elegant way to do it, but @&# and commands like those are still hard to handle for me, and I could not work it out Ruth === Subject: Re: normalize a table I want to do something really simple, which is take a table made of > pairs and normalize the first number in each pair by dividing by the > largest. For instance, I want to transform this list {{1,0.2},{2,0.3},{3,0.4},{4,0.5}} into this one {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} The way i did it is through the chain of commands firsttable={{1,0.2},{2,0.3},{3,0.4},{4,0.5}}; > top=Max[Table[firsttable[[i,1]],{i,1,Length[firsttable]}]]; > mytable=Do[newtable=ReplacePart[newtable,newtable[[i,1]]/top,{i, > 1}],{i,1,Length[firsttable]}] There must be a more elegant way to do it, but @&# and commands like > those are still hard to handle for me, and I could not work it out > Ruth Hi Ruth, Please, find hereunder three functions that illustrate some possible approaches to answer your question. What the most elegant code is, I leave it to you. In[1]:= data = {{1, 0.2}, {2, 0.3}, {3, 0.4}, {4, 0.5}}; In[2]:= Max[data] Out[2]= 4 In[3]:= data[[All,1]]/Max[data] Out[3]= {1/4, 1/2, 3/4, 1} In[4]:= {data[[All,1]]/Max[data], data[[All,2]]} Out[4]= {{1/4, 1/2, 3/4, 1}, {0.2, 0.3, 0.4, 0.5}} In[5]:= Transpose[{data[[All,1]]/Max[data], data[[All,2]]}] Out[5]= {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} In[6]:= myfun1[lst_] := Transpose[{lst[[All,1]]/Max[lst], lst[[All,2]]}] In[7]:= myfun1[data] Out[7]= {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} In[8]:= myfun2[lst_] := Module[{maxval = Max[lst]}, ({First[#1]/maxval, Last[#1]} & ) /@ lst] In[9]:= myfun2[data] Out[9]= {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} In[10]:= data /. {x_Integer, (y_)?NumericQ} -> {x/Max[data], y} Out[10]= {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} In[11]:= myfun3[lst_] := lst /. {x_Integer, (y_)?NumericQ} -> {x/Max[lst], y} In[12]:= myfun3[data] Out[12]= {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} Jean-Marc === Subject: Re: normalize a table There probably are shorter ways to do it, but I would work with the transposed table like this: trans = Transpose[firsttable] new = Transpose[{trans[[1]]/Max[trans[[1]]], trans[[2]]}] I want to do something really simple, which is take a table made of > pairs and normalize the first number in each pair by dividing by the > largest. For instance, I want to transform this list {{1,0.2},{2,0.3},{3,0.4},{4,0.5}} into this one {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} The way i did it is through the chain of commands firsttable={{1,0.2},{2,0.3},{3,0.4},{4,0.5}}; > top=Max[Table[firsttable[[i,1]],{i,1,Length[firsttable]}]]; > mytable=Do[newtable=ReplacePart[newtable,newtable[[i,1]]/top,{i, > 1}],{i,1,Length[firsttable]}] There must be a more elegant way to do it, but @&# and commands like > those are still hard to handle for me, and I could not work it out > Ruth === Subject: Re: normalize a table Hi Ruth this should work fine: With[{max = Max[Transpose[firsttable][[1]]]}, Transpose[{Map[#/max &, Transpose[firsttable][[1]]], Transpose[firsttable][[2]]}]] Or you can put it in a function: NormTable[ftab_] := With[{max = Max[Transpose[ftab][[1]]]}, Transpose[{Map[#/max &, Transpose[ftab][[1]]], Transpose[ftab][[2]]}]] Guido With transpose you can change between nor I want to do something really simple, which is take a table made of > pairs and normalize the first number in each pair by dividing by the > largest. For instance, I want to transform this list {{1,0.2},{2,0.3},{3,0.4},{4,0.5}} into this one {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} The way i did it is through the chain of commands firsttable={{1,0.2},{2,0.3},{3,0.4},{4,0.5}}; > top=Max[Table[firsttable[[i,1]],{i,1,Length[firsttable]}]]; > mytable=Do[newtable=ReplacePart[newtable,newtable[[i,1]]/top,{i, > 1}],{i,1,Length[firsttable]}] There must be a more elegant way to do it, but @&# and commands like > those are still hard to handle for me, and I could not work it out > Ruth === Subject: Re: normalize a table I want to do something really simple, which is take a table made of > pairs and normalize the first number in each pair by dividing by the > largest. For instance, I want to transform this list {{1,0.2},{2,0.3},{3,0.4},{4,0.5}} into this one {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} The way i did it is through the chain of commands firsttable={{1,0.2},{2,0.3},{3,0.4},{4,0.5}}; > top=Max[Table[firsttable[[i,1]],{i,1,Length[firsttable]}]]; > mytable=Do[newtable=ReplacePart[newtable,newtable[[i,1]]/top,{i, > 1}],{i,1,Length[firsttable]}] There must be a more elegant way to do it, but @&# and commands like > those are still hard to handle for me, and I could not work it out > Ruth There are many ways to do it. Here are four. In[1]:= firsttable = {{1,0.2},{2,0.3},{3,0.4},{4,0.5}}; Transpose@MapAt[#/Max@#&, Transpose@firsttable, 1] Transpose@{#[[1]]/Max@#[[1]],#[[2]]}&@Transpose@firsttable Transpose@ReplacePart[#,#[[1]]/Max@#[[1]],1]&@Transpose@firsttable Transpose@{firsttable[[All,1]]/Max@firsttable[[All,1]], firsttable[[All,2]]} Out[2]= {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} Out[3]= {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} Out[4]= {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} Out[5]= {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} === Subject: Re: normalize a table I want to do something really simple, which is take a table made of > pairs and normalize the first number in each pair by dividing by the > largest. For instance, I want to transform this list {{1,0.2},{2,0.3},{3,0.4},{4,0.5}} into this one {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} The way i did it is through the chain of commands firsttable={{1,0.2},{2,0.3},{3,0.4},{4,0.5}}; > top=Max[Table[firsttable[[i,1]],{i,1,Length[firsttable]}]]; > mytable=Do[newtable=ReplacePart[newtable,newtable[[i,1]]/top,{i, > 1}],{i,1,Length[firsttable]}] There must be a more elegant way to do it, but @&# and commands like > those are still hard to handle for me, and I could not work it out > Ruth > Here is a newbie approach: In[9]:= ({#1[[1]]/Max[tbl[[All,1]]], #1[[2]]} & ) /@ tbl Out[9]= {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} J.87nos ---------------------------------------------- Trying to argue with a politician is like lifting up the head of a corpse. (S. Lem: His Master Voice) === Subject: Re: normalize a table Ruth, here is a solution based on transposition In[1]:= L = {{1, 0.2}, {2, 0.3}, {3, 0.4}, {4, 0.5}}; ((Transpose[{#1/Max[#1], #2}] & ) @@ Transpose[#1] & )[L] Out[2]= {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} Adriano Pascoletti I want to do something really simple, which is take a table made of > pairs and normalize the first number in each pair by dividing by the > largest. For instance, I want to transform this list {{1,0.2},{2,0.3},{3,0.4},{4,0.5}} into this one {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} The way i did it is through the chain of commands firsttable={{1,0.2},{2,0.3},{3,0.4},{4,0.5}}; > top=Max[Table[firsttable[[i,1]],{i,1,Length[firsttable]}]]; > mytable=Do[newtable=ReplacePart[newtable,newtable[[i,1]]/top,{i, > 1}],{i,1,Length[firsttable]}] There must be a more elegant way to do it, but @&# and commands like > those are still hard to handle for me, and I could not work it out > Ruth === Subject: Re: normalize a table Hi Ruth, There are many ways of doing it. Here are three potential options: firsttable /. {x_?NumericQ, y_?NumericQ} :> {x/Max[firsttable[[All,1]]], y} #/{Max[firsttable[[All,1]]], 1} & /@ firsttable Transpose[{firsttable[[All, 1]]/Max[firsttable[[All, 1]]], firsttable[[All, 2]]}] Good luck! I want to do something really simple, which is take a table made of > pairs and normalize the first number in each pair by dividing by the > largest. For instance, I want to transform this list {{1,0.2},{2,0.3},{3,0.4},{4,0.5}} into this one {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} The way i did it is through the chain of commands firsttable={{1,0.2},{2,0.3},{3,0.4},{4,0.5}}; > top=Max[Table[firsttable[[i,1]],{i,1,Length[firsttable]}]]; > mytable=Do[newtable=ReplacePart[newtable,newtable[[i,1]]/top,{i, > 1}],{i,1,Length[firsttable]}] There must be a more elegant way to do it, but @&# and commands like > those are still hard to handle for me, and I could not work it out > Ruth === Subject: Re: normalize a table I want to do something really simple, which is take a table made of > pairs and normalize the first number in each pair by dividing by the > largest. For instance, I want to transform this list {{1,0.2},{2,0.3},{3,0.4},{4,0.5}} into this one {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} The way i did it is through the chain of commands firsttable={{1,0.2},{2,0.3},{3,0.4},{4,0.5}}; > top=Max[Table[firsttable[[i,1]],{i,1,Length[firsttable]}]]; > mytable=Do[newtable=ReplacePart[newtable,newtable[[i,1]]/top,{i, > 1}],{i,1,Length[firsttable]}] There must be a more elegant way to do it, but @&# and commands like > those are still hard to handle for me, and I could not work it out > Ruth Hi Ruth, what about data = {{1, 0.2}, {2, 0.3}, {3, 0.4}, {4, 0.5}}; data[[All,1]] /= Max[data[[All,1]]]; data {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} ? Peter === Subject: Re: normalize a table Hi Ruth, assuming your list is stored in dat, try: dat[[All,1]] /= Max[dat[[All,1]]]; dat Daniel I want to do something really simple, which is take a table made of > pairs and normalize the first number in each pair by dividing by the > largest. For instance, I want to transform this list {{1,0.2},{2,0.3},{3,0.4},{4,0.5}} into this one {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} The way i did it is through the chain of commands firsttable={{1,0.2},{2,0.3},{3,0.4},{4,0.5}}; > top=Max[Table[firsttable[[i,1]],{i,1,Length[firsttable]}]]; > mytable=Do[newtable=ReplacePart[newtable,newtable[[i,1]]/top,{i, > 1}],{i,1,Length[firsttable]}] There must be a more elegant way to do it, but @&# and commands like > those are still hard to handle for me, and I could not work it out > Ruth === Subject: Creating Dicom Images with 16 Bit format Hi All, I was working on Dicom format by using Mathematica Well I am learning about Dicom from ( http://medical.nema.org/ ) . Now I can write 16 Bit Images in mathematica. But the strange thing i found is that when I change the pixel information of the Dicom files . the exported file [modified Dicom] contains very few tags. Please can u tell me How can I change the pixel information without changing other tags. My aim is to change the pixel information of dicom files for eg : i want to change the pixel values between 200 and 400 to 700 which I can do it in Mathematica and write a New dicom file containing all tages + this modified pixel information. Is it possible to do it. ?? # th.92s is very important for my thesis topic !! Please kindly help me with the information. thannks in advance Danny === Subject: text equation I have the following text Cell[TextData[{ [CapitalEpsilon][Iota][Sigma][Alpha][Gamma][Omega][Gamma]: 03ae [Sigma][Tau][Omicron] , StyleBox[Mathematica, FontSlant->Italic], }], Text] It is a text expression whith Greek words. (the translation is: Introduction to Mathematica) However, I can't find how to make the greek characters not appear in italic format. Dimitris === Subject: Re: text equation Hi Dimitris, you may have noticed FontSlant->Italic in your expression. Changing this to FontSlant->Plain changes the Latin characters but not the Greek one's. This leads to the conclusion that in the font used, plain and italic Greek characters share the same definition. I tried the fonts: Courier,Times,Helvetica with the same result. Another observation is that not all Greek characters are slanted, e.g. eta is not. Daniel > I have the following text Cell[TextData[{ [CapitalEpsilon][Iota][Sigma][Alpha][Gamma][Omega][Gamma]:0 3ae > [Sigma][Tau][Omicron] , > StyleBox[Mathematica, > FontSlant->Italic], > > }], Text] > It is a text expression whith Greek words. > (the translation is: Introduction to Mathematica) However, I can't find how to make the greek characters not appear in > italic format. Dimitris > === Subject: Re: text equation > I have the following text Cell[TextData[{ [CapitalEpsilon][Iota][Sigma][Alpha][Gamma][Omega][Gamma]:0 3ae > [Sigma][Tau][Omicron] , > StyleBox[Mathematica, > FontSlant->Italic], > > }], Text] > It is a text expression whith Greek words. > (the translation is: Introduction to Mathematica) However, I can't find how to make the greek characters not appear in > italic format. Dimitris > Hi Dimitris, it _is_ plain! Compare the appearance with: Cell[TextData[{ StyleBox[[CapitalEpsilon][Iota][Sigma][Alpha][Gamma][Omega][ Gamma] :03ae [Sigma][Tau][Omicron] Mathematica, Rule[FontSlant, Italic]], }], Text] Peter === Subject: RE: A Series test Mathematica 5.2.0.0 on Win XP gives: (a - I*x)/(a + I*x) -----Original Message----- === Subject: A Series test Just curious. Could somebody pls run this script on the latest Mathematica user version (I think it's 5.2) under Windows or Unix and report the results: rho=(x+a*I)/(x-a*I); R=Abs[rho]; s=Series[R,{x,0,4}]; Print[FullSimplify[s,a>=0&&x>=0]//InputForm]; My 5.0 answer (Mac G5 under OS 10.4.8) is SeriesData[x, 0, {1, (-2*I)/a, (-2*(1 + Derivative[2][Abs][-1]))/a^2, (((2*I)/3)*(3 + 6*Derivative[2][Abs][-1] - 2*Derivative[3][Abs][-1]))/ a^3, (2*(3 + 9*Derivative[2][Abs][-1] - 6*Derivative[3][Abs][-1] + Derivative[4][Abs][-1]))/(3*a^4)}, 0, 5, 1] The correct answer is 1. (The result with Simplify is more ****** This e-mail and any files transmitted with it are proprietary and intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of ITT, Inc. The recipient should check this e-mail and any attachments for the presence of viruses. ITT accepts no liability for any damage caused by any virus transmitted by this e-mail. ****** === Subject: NIntegrate and the number of grid points used Hoi zame, I am using NIntegrate to run a few experiments. I wonder whether there is a possibility to get access to the number of points used by Mathematica? That would be helpful. Thomas === Subject: Re: NIntegrate and the number of grid points used Hi THomas, you could e.g. try: count=0; NIntegrate[Sin[x],{x,0,Pi},EvaluationMonitor:>++count]; count Daniel > Hoi zame, I am using NIntegrate to run a few experiments. I wonder whether there is a > possibility to get access to the number of points used by Mathematica? That > would be helpful. Thomas === Subject: Re: NIntegrate and the number of grid points used > Hoi zame, I am using NIntegrate to run a few experiments. I wonder whether there is a > possibility to get access to the number of points used by Mathematica? That > would be helpful. Thomas Hi Thomas, NIntegrateWithCount[exp_, rg_, opt___] := Module[{cnt = 0}, {NIntegrate[exp, rg, EvaluationMonitor :> cnt++, opt], cnt}]; NIntegrateWithCount[Sin[x]/(Pi - x), {x, 0, Pi}] --> {1.8519370519824667, 11} NIntegrateWithCount[Sin[x]/(Pi - x), {x, 0, Pi}, WorkingPrecision -> 32] --> {1.8519370519824661703611, 21} see http://documents.wolfram.com/mathematica/book/section-3.9.10 or read this chapter in Mathematica's help browser. Peter === Subject: Re: NetLink programs and Mathematica license Given the DRM that comes with Mathematica, you should easily be able to figure out the terms of your license by trying to distribute your program. If you're not allowed to do it, then it probably won't work. > Hello to all users, i'm writing a C# program that use Mathematica (V5.1) via NetLink and an > (self-made) package for drawing graphs. In case of distributing my (compiled) code, does every other user need > a license of Mathematica? > What kind of restrictions are there for developing NetLink programs? I > know that the inclusion of the DLL is a minimum requirement. > -- http://chris.chiasson.name/ === Subject: Re: NetLink programs and Mathematica license Probably not the right way to go. Why not contact WRI directly and ask them? > Given the DRM that comes with Mathematica, you should easily be able > to figure out the terms of your license by trying to distribute your > program. If you're not allowed to do it, then it probably won't work. Hello to all users, i'm writing a C# program that use Mathematica (V5.1) via NetLink and an > (self-made) package for drawing graphs. In case of distributing my (compiled) code, does every other user need > a license of Mathematica? > What kind of restrictions are there for developing NetLink programs? I > know that the inclusion of the DLL is a minimum requirement. -- > http://chris.chiasson.name/ === Subject: NetLink programs and Mathematica license Hello to all users, i'm writing a C# program that use Mathematica (V5.1) via NetLink and an (self-made) package for drawing graphs. In case of distributing my (compiled) code, does every other user need a license of Mathematica? What kind of restrictions are there for developing NetLink programs? I know that the inclusion of the DLL is a minimum requirement. === Subject: Re: NetLink programs and Mathematica license you would need a full Mathematica installation to run you NetLink program because you launch a full Kernel and a Frontend ... Jens > Hello to all users, i'm writing a C# program that use Mathematica (V5.1) via NetLink and an > (self-made) package for drawing graphs. In case of distributing my (compiled) code, does every other user need > a license of Mathematica? > What kind of restrictions are there for developing NetLink programs? I > know that the inclusion of the DLL is a minimum requirement. === Subject: what could cause a function call to not print during TracePrint? I have a function, XML`DocBook`Private`toStringKernel, that is being called (because I can see it on the stack when I use Wolfram Workbench to break at a message that is being thrown from inside XML`DocBook`Private`toStringKernel), but which is not printed when I use TracePrint[ some command hat eventually calls XML`DocBook`Private`toStringKernel, _XML`DocBook`Private`toStringKernel ] Furthermore, the debugger seems unable to stop at the breakpoint I have set at the definition of toStringKernel inside DocBook.m So, what could cause a function to be invisible to TracePrint and/or the WW debugger? BTW, I already tried TracePrint with TraceInternal->True and had no luck. Simple TracePrints work well: In[1]:= System`Dump`$MessagesInHelpBrowserAreKnown=False; aaaa[_]:=(Message[aaaa::argb,aaaa,1,2,4];Abort[]) TracePrint[1;2;3;XML`MathML`ExpressionToMathML[1];aaaa[4],_aaaa] === Subject: Export to xmgrace format Hi all, I have some colleagues who are nuts for xmgrace. I can't stand it; I do all my analysis, fitting and graphics creation in Mathematica. However, it's gotten to be such a headache fighting with these guys over the graphics format that I was hoping to find some way to export graphics into an xmgrace format that would make them happy. Does anybody know of such a package? Xerxes === Subject: Series of LaguerreL problem Using 5.2 version and looking at the help browser on LaguerreL[] function I see the following line In[1]:= Series[LaguerreL[n, z], {z, 0, 4}] Out[1]:= SeriesData[z, 0, {LaguerreL[n, 0], -LaguerreL[-1 + n, 1, 0], LaguerreL[-2 + n, 2, 0]/2, -LaguerreL[-3 + n, 3, 0]/6, LaguerreL[-4 + n, 4, 0]/24}, 0, 5, 1] Does it have any sense? Certainly, I can call FunctionExpand[] on the Normal[%] The behaviour of version 5.0 was different and I suspect bug here. Explanation/motivation or bug confirmation would be wellcome. -- Arturas Acus === Subject: Re: [TS 503]--Re:OverVector Context Bytes: 3917 Tom, You'll see the difference if you put something like Subscript in place of OverVector. Subscript is in the System` context. OverVector doesn't have a context defined, but somehow still has formatting rules (meaning Mathematica is looking at only the local name of the symbol to do the formatting in the case of OverVector). BeginPackage@Heh`; Begin@`Private`; OverVector@b; Context@OverVector On Fri, 12 Jan 2007 14:00:00 UT, support@wolfram.com > -- Wolfram Research Technical Support -- This is a response to your email. > The reply to your question can be found at the bottom of this message. > Our classification number for this message is: [TS 503] > Please give this number in any future correspondence > related to this question. If you leave this number in === > the Subject: header in the form [TS 503], it will > automatically be reassigned to the original technician. > === > Subject: OverVector Context OverVector doesn't have a context at the beginning of a session BeginPackage@Heh`; > Begin@`Private`; > OverVector@b; > Context@OverVector gives Heh`Private` I guess this is somewhat useful because it allows package authors to > give DownValues values to OverVector@arg without worrying about the > effect in another package. However, I am wondering why the Context is > any different from, say, Subscript? It just seems weird to have default formatting rules for symbols (like > OverBar and OverVector) with certain local names but any Context name. -- > http://chris.chiasson.name/ _ > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Chris, Unless I am missing something, I think how and why of this is covered in > the Documentation for BeginPackage. There is also an FAQ at: http://support.wolfram.com/mathematica/packages/writing/context.html and other package writing FAQs at: http://support.wolfram.com/mathematica/packages/writing/ If there are examples that don't fit the described behavior, please > send them in. Tom Zeller > Wolfram Research Technical Support ---------------------------------------------------------------------------- If this issue is resolved, please consider taking a few minutes > to give us some feedback on your experience. Please visit > http://support.wolfram.com/survey/?trackingnumber=503 > and give your honest answers to these three short questions. > -- http://chris.chiasson.name/ === Subject: Re: Nminimize: Give Initial values to Decision Variables Hi Pratim, if you can spezify a ringe in which the variables for the minimum lie, you can spezify this in the first Slot of NMInimize.E.g. assume that form f[x,y]= (x - 3)^2 + (y - 5)^2 it is know that xmin is in 2..4 and ymin in 4..6: NMinimize[{(x - 3)^2 + (y - 5)^2, 2 < x < 4, 4 < y < 6}, {x, y}] Daniel > I have a nonlinear problem thta I am attemting to solve using NMinimize (NelderMead method). > I would like to give good initial values to my decision variables say, x1, x2. > Is there a way (command) to do that with Mathematica? > > > Pratim === Subject: Re: mathematica on linux Bytes: 2488 > I just finished installing Mathematica 5.2 on my linux box and I was > hoping that there would be some progress from version 5 which I > installed a couple of years ago. Sadly, the same problems with font > rendering, primitive user interface, rotated labels, and a lack of > features as compared to the Windows version persist. Yes. I upgraded my distro recently and Mathematica is now horribly broken. :-( > Is there any plan of shifting to a QT/GTK based system in the next > version? Given that Mathematica's GUI makes little use of the widget toolkit, I'd recommend targetting OL and WPF. Presenta does this using a relatively small amount of code: http://www.ffconsultancy.com/products/presenta/ It is about 1,000x faster than Mathematica as a consequence... > What are people's experience with running the Windows version using > wine on Linux? I'm running while referencing a License server. Will > wine be able to communicate with the license server? I've never tried Mathematica under Wine. Isn't a Mathematica license single platform? > Please don't ignore us Linux users! Most clusters run on Linux, and a > lot of scientific software runs on Linux so dual booting is quite a > pain in the butt. Plus, with Windows Vista requiring 2 gajillion > dollars for a copy, buying windows is a bit out of reach now. Do some work for Microsoft and get a free copy. ;-) -- Dr Jon D Harrop, Flying Frog Consultancy http://www.ffconsultancy.com/products/ocaml_for_scientists/index.html?usenet === Subject: Sorting by date Hi All, I have a list of lists that looks like so: {{3, 137.5, 13978, {2005, 2, 8}}, {3, 138.5, 12519, {2005, 1, 4}}, {3, 171.9, 15835, {2005, 4, 12}}, {3, 142.8, 17137, {2005, 11, 19}}, Cliff === Subject: Re: Sorting by date Hi Cliff, let's call ld your list, so: ld[[Ordering[ld[[All, {4}]]]]] is the sorted list according to the dates. ~Scout~. Clifford Martin ha scritto nel messaggio > Hi All, I have a list of lists that looks like so: > {{3, 137.5, 13978, {2005, 2, 8}}, {3, 138.5, 12519, {2005, 1, 4}}, {3, > 171.9, 15835, {2005, 4, 12}}, {3, 142.8, 17137, {2005, 11, 19}}, > {3, 161.1, 18881, {2006, 1, 18}}, {3, 108.7, 20055, {2006, 2, 28}}, {3, The last element per vector is a date. I'd like to sort the list so that > the vectors are arranged in ascending order of date, i.e. the vector > {2006,9,14} should be last. Any help would be appreciated. > Cliff > === Subject: Possible to Create 16 Bit Dicom Images in Mathematica 5.2?? Is it possible to create 16 bit images in Dicom format in Mathematica 5.2 ?? Basically I want to take Dicom files and then modify them ( To remove some artifacts with image processing package) and create new Dicom files in 16 Bit . Is it possible ?? dannny === Subject: Re: Possible to Create 16 Bit Dicom Images in Mathematica 5.2?? Hi Jean , I was working on Dicom format by using Mathematica Well I am learning about Dicom from ( http://medical.nema.org/ ) . Now I can write 16 Bit Images in mathematica. But the strange thing i found is that when I change the pixel information of the Dicom files . the exported file [modified Dicom] contains very few tags. Please can u tell me How can I change the pixel information without changing other tags. My aim is to change the pixel information of dicom files for eg : i want to change the pixel values between 200 and 400 to 700 which I can do it in Mathematica.] and write a New dicom file containing all tages + this modified pixel information. Is it possible to do it. ?? # th.92s is very important for my thesis topic !! Please kindly help me with the information. thannks in advance Danny === Subject: Re: Re: Limit and Root Objects > In fact, Vassiliev gives the exact number only in the case when d > is prime, post on this topic. Andrzej Kozlowski === Subject: Re: sparsearray and its nonempty cells Of course I can simply use Sort but I would prefer to obtain already sorted list directly from Mysparse/. SparseArray[_, _, _, x_] :> x[[2, 2]] or from ArrayRules[...]. BTW Most[First/@ArrayRules[Mysparse]] does not produce sorted list In practice I have very long list Mysparse/. SparseArray[_, _, _, x_] :> x[[2, 2]] and I want to take the maximum of it. This searching takes some time. If I would have sorted list (given in advance) I would take the last element. Take again: Out[279]= SparseArray[i_ /; 2 .89ÅÛ i .89ÅÛ 4 :> A, 6] In[280]:= % /. SparseArray[_, _, _, x_] :> x[[2,2]] {{3}, {2}, {4}} and: SparseArray[i_ /; 2 .89ÅÛ i .89ÅÛ 4 :> A, 6]//Trace {{i_ /; 2 .89ÅÛ i .89ÅÛ 4 :> A, i_ /; 2 .89ÅÛ i .89ÅÛ 4 :> A}, SparseArray[i_ /; 2 .89ÅÛ i .89ÅÛ 4 :> A, 6], {2 .89ÅÛ 1 .89ÅÛ 4, False}, {2 .89ÅÛ 2 .89ÅÛ 4, True}, {2 .89ÅÛ 3 .89ÅÛ 4, True}, {2 .89ÅÛ 4 .89ÅÛ 4, True}, {2 .89ÅÛ 5 .89ÅÛ 4, False}, {2 .89ÅÛ 6 .89ÅÛ 4, False}, SparseArray[<[InvisibleSpace]3[InvisibleSpace]>, {6}]} Note, that True is for 2, 3 and 4 - ordered! Wht do you think? Arek dh napisa.81[Hyphen](a): > Hi Arek, > if you say: Mysparse // FullForm you will see that the array is not > stored in ascending order as you imply. To get your output sorted, > simply wrap Sort around it. > Daniel > I bulit the following sparse array Mysparse=SparseArray[i_ /; 2 .89ÅÛ i .89ÅÛ 11 :> 0.8, 20] in order to find out all nonempty cells in this array I call (I want to > avoid Normal) > Mysparse/. SparseArray[_, _, _, x_] :> x[[2, 2]] and I get {{8}, {11}, {3}, {7}, {2}, {6}, {10}, {9}, {5}, {4}} This is of course correct, but why it is not sorted???? How can I build Mysparse to get sorted list of nonempty cells? Arek > === Subject: Re: sparsearray and its nonempty cells Are you sure Mysparse is defined well? This is what I got: In[1]:= Quit In[1]:= Mysparse = SparseArray[i_ /; 2 = i = 11 :> 0.8, 20] Set::nosym : i_ /; 2 does not contain a symbol to which to attach a rule. Out[1]= SparseArray[] In[3]:= Sort[{{8}, {11}, {3}, {7}, {2}, {6}, {10}, {9}, {5}, {4}}] Out[3]= {{2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}} Dimitris I bulit the following sparse array Mysparse=SparseArray[i_ /; 2 .89ÅÛ i .89ÅÛ 11 :> 0.8, 20] in order to find out all nonempty cells in this array I call (I want to > avoid Normal) > Mysparse/. SparseArray[_, _, _, x_] :> x[[2, 2]] and I get {{8}, {11}, {3}, {7}, {2}, {6}, {10}, {9}, {5}, {4}} This is of course correct, but why it is not sorted???? How can I build Mysparse to get sorted list of nonempty cells? Arek === Subject: Re: An Introduction to Programming with Mathematica, Third Edition Yes, I have third edition. And strictly, in my opinion, there is no info about object-oriented methods. However it all depends on what you define as OBJECT. Look at http://library.wolfram.com/infocenter/Conferences/5773/ and you will find out that ******* Parts of Mathematica are already object-oriented Front-End Programming NDSolve Method Plug-in Framework ************ and frond-end programming is described in the book. Best Arek dimitris napisal(a): > Hello to all! I have a copy of the An Introduction to Programming with Mathematica, > Second Edition > by Graylord et al. Recently, I visited a bookstore and I take a quick look of the third > edition (2005). > Even though the outer (description) page states that Object Oriented > Programming is covered along other programming aspects I was not able > to find anything relevant neither inside the book, nor in the index. So, I didn't buy it. Does anyone own this edition? > If yes, am I right or wrong? > Dimitris === Subject: Re: An Introduction to Programming with Mathematica, Third Edition Dmitris, I think you have misread the text on the back cover. The last part of the back cover says (http://www.cambridge.org/catalogue/catalogue.asp?isbn=9780521846783): This is the ideal text for all scientific students, researchers, and programmers wishing to deepen their understanding of Mathematica, or even those keen to program using an interactive language that contains programming paradigms from all major programming languages: procedural, functional, recursive, rule-based, and object-oriented. It does not claim that the book covers object-oriented programming, it merely states that the text is useful to people that are keen to an, among others, object-oriented programming language. The word object is not even mentioned in the book's index! So you are right, this book does _not_ cover OOP, and there is no contradiction between the book's contents and the back cover. In the first place, your question is due to a misconception of the text on the back cover of the book. /Sigmund === Subject: On AspectRatio I have taken the following command from Help on AspectRatio. Show[Graphics[Circle[{0, 0}, 1], AspectRatio -> Automatic]]; This does not give an aspect ratio of 1 on my monitor. In fact when I measure the ratio of the height to width of the circle (or the surrounding box) generated by this command it is greater than 1.0. This is also true for Show[Graphics[Circle[{0, 0}, 1], AspectRatio -> 1.0]]; Am I interpreting this option correctly? In any case would you please tell me how I can get the height to width ratio = 1.0 . My application is parametric plots (phase-plane analysis) and I need the aspect ratio to be exactly one. --V. Stokes === Subject: Re: speed of multiplying polynomials > All this is true but the essential question -- one that David Harvey > alluded to in his original post -- is why does Mathematica not do this > automatically? For example, multiplication of large integers and > high-precision approximate numbers is done using interleaved schoolbook, > Karatsuba, three-way Toom-Cook and number-theoretic transform algorithms. Actually, there is another issue. I have tried ListConvolve for a few cases, and compared its performance to polynomial multiplication in certain other computer algebra systems. For large degree, small coefficient problems (say degree 10000, coefficients in [0, 1000]), Mathematica is definitely in the same ball park, maybe still a little slower, but not hugely slower. But for small degree, larger coefficients (say degree 100, coefficients in [0, 10^500]), Mathematica was something like 20 times slower. Is ListConvolve really the best Mathematica can do? I mean, if someone really desperately needs to multiply polynomials in Mathematica, I find it difficult to believe that the best they can do is still twenty times slower than other systems. Of course they could go out and write the multiplication code in C or something themselves, but that's missing the point :-) David === Subject: Re: speed of multiplying polynomials > Actually, there is another issue. I have tried ListConvolve for a few > cases, and compared its performance to polynomial multiplication in > certain other computer algebra systems. ... > But for small degree, larger coefficients (say degree 100, coefficients > in [0, 10^500]), Mathematica was something like 20 times slower. I bet it is incrementally adding up large numbers. For example, if I have 1000 numbers c[0], ..., c[999], and those numbers are big, then the obvious algorithm (in C): for(i=0, sum=0; i < 1000; i++) sum += c[i]; is a disaster. Each addition will be linear time in the length of the partial sum, which is O(n^2). Adding up n numbers with n digits this way is O(n^3), whereas a divide-and-conquer approach would be O(n^2). I have no idea if Mathematica in fact does this, but the mistake is surprisingly common. People do this with polynomials as well as integers, and then they wonder why their algorithms are slow. It doesn't matter if it's coded in C, this happens whenever the object being constructed is large (ie: more than a machine word). === Subject: Re: speed of multiplying polynomials > I bet it is incrementally adding up large numbers. For example, if I > have 1000 numbers c[0], ..., c[999], and those numbers are big, then > the obvious algorithm (in C): for(i=0, sum=0; i < 1000; i++) > sum += c[i]; is a disaster. Sorry, this is nonsense. I was confusing addition with multiplication. === Subject: Re: Integration using mathematica > I have difficulty in integrating the following equation on Mathematica. > Does any one of you know how to do it on Mathematica? Any trick to > aply? or another software to use? Please help me. The function is as > follows: 0.013 *Exp [15.16(ArcTan(0.002 x)])^2 *(ArcTan(0.002 x) Using the correct syntax (and correct number of parentheses too) should help. Among many others, you could check the following documents: How are the different brackets, such as { }, [ ], and ( ), used in Mathematica? http://support.wolfram.com/mathematica/kernel/features/brackets.html Also http://documents.wolfram.com/mathematica/functions/Integrate and http://documents.wolfram.com/mathematica/functions/NIntegrate Jean-Marc === Subject: Re: Integration using mathematica your expression has syntax errors. I assume you mean: 0.013 *Exp [15.16(ArcTan[0.002 x]]^2 *ArcTan[0.002 x] For an example I set all numerical constant to 1, you can put them back yourself. t1=Exp [ 2 ArcTan[x] ] *ArcTan[x] this calls for substitution of ArcTan[x] by a new variable y. dx is thereby transformed into: (1+x^2 )dy= (1+Tan[y]^2) dy. And the integral: t2=Integrate[ Exp[2 y] y (1 + Tan[y]^2), y]//Simplify Finally we replace x back: t3=t2/.y->ArcTan[x]//Simplify You may make a quick check by verifying that D[t3,x]-t1 gives zero if you replace x by a numerical value. Daniel > I have difficulty in integrating the following equation on Mathematica. > Does any one of you know how to do it on Mathematica? Any trick to > aply? or another software to use? Please help me. The function is as > follows: 0.013 *Exp [15.16(ArcTan(0.002 x)])^2 *(ArcTan(0.002 x) === Subject: Re: Re: Limit and Root Objects I hope my paraphrase of Adam Strzebonski's proof has made it easier for those who are interested to follow, but since I feel a little embarrassed as an algebraic topologist that I did not notice this topological proof immediately myself and had to rely on help form an algebraic geometer I would like to atone for this by providing a topological interpretation of Adam's argument. While this is not directly relevant to Mathematica, I think it can be quite illuminating for anyone interested in solutions of polynomial equations (and in particular in the question why we need things like Root objects). Besides it shows that even elementary topology can teach us some quite useful things. Let me start with an object, which I think must be the most familiar to the general public and non-trivial, object from algebraic topology - the Moebius band. In fact, the Moebius band is very closely related to Adam's proof. The Moebius band can easily be contructed by anyone: all you need to do is to cut a rectangular piece of paper and then glue two opposite sides. If you glue them in the straight forward way you will get a topological space called the (cartesian) product of a circle and an interval. If you give the band a twist before gluing the ends you will get a twisted product or a Moebius band; let's call it M. Now, both the untwisted product and the twisted product can be continuously mapped (projected) onto a circle X so that the inverse image of each point on a circle is an interval. This kind of projection p: M -> X is called a fibre bundle; in the untwisted case you have a trivial fibre bundle and in the twisted case one that is only locally trivial. The inverse images p^(-1)(x) of the points x on the circle X are called fibres - note that as you go over a circle the fibres of the trivial bundle all point in the same direction but the fibres of the twisted one keep turning until when you travel all the way round the circle you find that the fibre has turned through 180 degrees and is pointing the opposite way. The projection map of the twisted product onto a circle admits a continuous section, that is a map s: X-> M such that p(s(x)) == x for each point x in X. For example for each x in X you take as s(x) the midpoint of the interval that is the fibre over x. Of course the same is true for the non-twisted product. But now, let's remove from the twisted (and the untwisted) product all the points except those on the boundary. In the case of the untwisted product you will get a pair of disjoint circles. But in the case of the twisted product you will get a single twisted circle. This twisted circle is mapped by the restriction of the projection map p onto the original base circle X forming a so called non-trivial double covering. It has the property that the fibre over any point in X now consists of just two points. The same of course is true for the trivial covering that maps two disjoint circle onto the original base circle X. However, the trivial covering admits of course two continuous sections: you can map the points on the base circle either into one or the other of the circles that map onto it. On the other hand, for the non-trivial covering no such continuous section can exist. If you try to construct one by starting at a point of the base circle and going around it you will find that by the time you arrive at that same point having traversed the entire circle you will be on the wrong sheet of the covering. Such connected non-trivial coverings of a circle exist for any positive integer n, there are connected double coverings, triple coverings and there are connected non-trivial d- fold coverings. And it is this fact that lies behind Adam's proof. In Adam's proof one first constructs a circle in the space of polynomials with the discriminant removed. Not just any circle will do: you have to choose a circle which has the property that it cannot be continuously contracted to a point without passing through a polynomial (remember, the points of the space are all polynomials of degree d) which has multiple roots. The roots of the polynomials that form the points of this circle together make up a twisted d-fold covering over this circle, and this covering, as we have seen earlier does not admit a continuous section. If you could choose continuously a root of each polynomial on the circle than of course you would have such a section - and this is impossible. Andrzej Kozlowski > I have decided to make one more attempt, although I really can't > afford to spend this time - I am under a lot of pressure form other > things I have to do. But if this does not work than nothing else will. I am simply going to re-write Adam's proof using more words, which > ought to make it a little clearer. Consider again the space of all monic polynomials of degree d, with > complex coefficients. These are object of the form: x^d + a(1) x^(d-1)+ ... + a(d), where a(i) are complex numbers. Any > such polynomial can be identified wiht the ordered d-tuple > (a(1),...,a(d)) , so the space of polynomials has a topology which is > just the topology of C^d - the d-fold Cartesian product of the > complex numbers. We shall therefore identify the space of polynomials > with C^d. > In the usual way we will remove from this space the space S > consisting of all those monic polynomials with multiple roots. We > will show that one cannot define a continuous root function on the > space C^d-S . Since C^d-S is a subspace of C^d, if one cannot define > a continuous root function on C^d-S then one obviously can't do so on > the larger space C^d. > Now suppose there is a continuous function, lets call it R (nothing > to do with Mathematica's Root - it was unfortunate that Adam used > this name), from C^d-S to the complex numbers C, which has the > property that for any polynomial p in C^d-S, R(p) is a root of p. We > will show that the assumption that such an R exists leads to a > contradiction. O.K> so suppose we have R: C^d-S -> C and R(p) is a > root of p and R is continuous. Now consider the following loop in the > space C^d-S; going from the polynomial x^d -1 to itself. A loop on a > space X is a continuous function f:[0,1] -> X such that f(0)=f(1), > where [0,1] denotes the unit interval. Our loop is defined as follows > f(t) = x^d- Exp[2Pi I t] . Note that this is always always a > polynomial wihtout multiple roots, and that f(0) = f(1) = x^d - 1, > in other we start with the polynomial x^d -1 and then continuously > move in the space of polynomials until we get back to the same > polynomial. (A technical comment: homotopy classes of such loops form > a group called the fundamental group of the space on which these > loops are defined. If this group is the zero group then the space is > simply connected. The main point of the argument is that the space > C^d-S is not simply connected and its fundamental group is a famous > group called Artin's group on d -strings). O.K., now we compose out > loop with our continuous function root, which we are assuming to > exist. So we get a continuous function g(t) = root(f(t)) = root(x^d- > Exp[2Pi I t]). Note that since g(t) is a root of x^d- Exp[2Pi I t]. > that means that it must satisfy this equation, that is g(t)^d == Exp > [2Pi I t]. so in particular the values of g(t)lie in the unit circle. > O.K. now since g(t)^d = Exp[2Pi I t], we must have > g(t) == E^((2 I Pi t+2 I Pi k(t))/d) > where k(t) is some integer depending on t. But since g(t) must be > continuous and k(t) must always be an integer, then it clearly must > be always constant. So actually g(t)=E^((2 I Pi t+2 I Pi k )/d), > where k is a fixed integer. O.K. now put into this t=0 and t=1. We > get g(0)= E^((2 I Pi k )/d) and g(1) = E^((2 I Pi ( k+1 )/d), which > are not equal. But look, f is a loop, so f(0) = f(1). But that mean > root(f(0)) == root(f(1)). But that means we must have g(0) = g(1). So > we have a contradiction. This means that no such function root can > exists. > The proof is complete, and no animation or anything else can disprove > it. ANdrzej Kozlowski >> I am sorry but I am about to give up. Let me explain it again but >> for the last time really. And please do not send me any animations >> because I never look at them. To tell the truth I have not even >> looked at one of them. Everything I have written and am writing is >> well known mathematics and it is you who are completely confused. >> The point is this. It is possible to define a continuous function >> from the set of complex polynomials of degree d with the topology >> given by considering the coefficients as elements of C to the >> topological space consisting of unordered d-tuples {x1,x2,...,xd}, >> with the topology of the so called symmetric product of C. In >> intuitive language, the set of roots as set or un-ordered d-tuple >> does depend continuously on the coefficients of the polynomial. But >> it is impossible to continuously choose one root out of this >> unordered set and obtain in this way a continuous function on the >> space of all complex polynomials (or even on the smaller space of >> polynomials minus the determinant). It is impossible intuitively >> because there is no natural way to choose one root out of an >> unordered set. In more precise topological language the reason is >> that you are dealing with a non trivial covering space, which does >> not have a global continuous section. This is what Adam's proof >> shows. It has nothing whatever to do with Root objects, Mathematica >> but it is only mathematics and well known mathematics, so there can >> be no dispute about it. >> then you should just accept that topology, even basic one is not >> something that very congenial to you, and leave it at that. >> Anyway, I can't devote any more time or effort to this matter. If >> any body else would like to try (Adam) then please do. >> Alternatively, perhaps you should write to a mathematical site, for >> example you could try the Hopf topology group run by Don Davies, >> dmd1@lehigh.edu , and ask about this matter and perhaps you will >> find somebody with better pedagogical skills then mine. There are >> also other sites run by professional mathematicians who answer >> general questions of this kind. Or you could try writing to Dave >> Rusin (rusin@math.niu.edu), he is a topologist and I think he likes >> answering questions of this kind. Also, he has much more >> experience, patience and pedagogical skill than me. >> Perhaps some other mathematicians on the list (Adam, Daniel ?) >> might want to explain it better, but as for me I am form now on >> only willing to discuss mathematica and not mathematics, and >> definitely not anything remotely topological. >> Andrzej Kozlowski > Well, I'm glad you didn't give up (and I didn't think you would). > I might > actually learn some formal mathematics. But as yet, I do not > follow Adam > Strzebonski's proof - nor am I certain exactly what the claims of > the proof > are. So let me state the matter in my own words. Given a one-parameter, say a, finite order, say order d, > polynomial with > real or complex coefficients, can we find a set of d root > functions which > are each continuous and which give the complete set of roots for the > polynomial for each value of a? I claim that the answer is yes. Let's say that it is not possible > to obtain > continuous exact algebraic roots, say with the Mathematica Root > function > (and I think that's what you and Strzebonski are saying). So with > Root we > obtain an indexed set of discontinuous root functions. But the > discontinuities are not unrelated. There are global relationships > between > the root functions. And specifically I'm claiming that we can > introduce a > pointwise reindexing function that will reindex the roots for each > value of > a, and that these new root functions can be made continuous. We > can even > make up a table of the new roots and fit an InterpolatingFunction > to them so > that we will have a set of true numerical root functions that are > each > continuous. Here are the examples again. Needs[Graphics`Animation`] > Needs[Graphics`Colors`] Routine to reindex at each value of a. rootindexedset[a_] := > Module[{roots = rootset[a], newroots, rootpermutations, > distances, pick}, > rootpermutations = Permutations[roots]; > distances = > Plus @@ Abs[Part[roots, #] - memoryrootset] & /@ > basepermutations; > pick = Part[Position[distances, Min[distances], 1], 1, 1]; > newroots = Part[roots, Part[basepermutations, pick]]]; > memoryrootset = newroots; > {a, #} & /@ newroots > ] Case 1 polynomial = x^5 - a x - 1 == 0; > displaypoly = polynomial /. a -> HoldForm[a]; > rootset[a_] = x /. Solve[polynomial, x] Calculating the reindexed root functions. memoryrootset = Null; > basepermutations = Permutations[Range[5]]; > roottables = Transpose@Table[rootindexedset[a], {a, -6., 10, 0.25}]; > Do[root[i] = Interpolation[Part[roottables, i]], {i, 1, Length > [roottables]}] Plot routine and animation frame[a_] := > Module[{locations}, > locations = {Re[#], Im[#]} & /@ Table[root[i][a], {i, 1, 5}]; > Show[Graphics[ > {LightCoral, AbsolutePointSize[15], > Point /@ locations, > Black, > MapThread[Text[#1, #2] &, {Range[5], locations}], Text[SequenceForm[a = , > NumberForm[a, {3, 2}, NumberPadding -> { , 0}]], > Scaled[{0.1, 0.95}], {-1, 0}]}], AspectRatio -> Automatic, > TextStyle -> {FontFamily -> Courier, FontSize -> 12, > FontWeight -> Bold}, > Frame -> True, > PlotRange -> {{-3, 3}, {-3, 3}}, > PlotLabel -> SequenceForm[Continuous Roots of , > displaypoly], > ImageSize -> 400] > ] Animate[frame[a], {a, -6, 10, 0.25}] > SelectionMove[EvaluationNotebook[], All, GeneratedCell] > FrontEndTokenExecute[OpenCloseGroup]; Pause[0.5]; > FrontEndExecute[{FrontEnd`SelectionAnimate[200, > AnimationDisplayTime -> 0.1, > AnimationDirection -> ForwardBackward]}] Case 2 polynomial = x^5 + (1 + I) x^4 - a x - 1 == 0; > displaypoly = polynomial /. a -> HoldForm[a]; > rootset[a_] = x /. Solve[polynomial, x]; memoryrootset = Null; > basepermutations = Permutations[Range[5]]; > roottables = Transpose@Table[rootindexedset[a], {a, -6., 10, 0.50}]; > Do[root[i] = Interpolation[Part[roottables, i]], {i, 1, Length > [roottables]}] Animate[frame[a], {a, -6, 10, 0.25}] > SelectionMove[EvaluationNotebook[], All, GeneratedCell] > FrontEndTokenExecute[OpenCloseGroup]; Pause[0.5]; > FrontEndExecute[{FrontEnd`SelectionAnimate[200, > AnimationDisplayTime -> 0.1, > AnimationDirection -> ForwardBackward]}] I'm not claiming that I know for certain that this can be done in > all cases, > or whether it might depend on how the parameter a enters into the > polynomial. I leave it to the mathematicians to correct me if > necessary or > make it sharper. But I think that it is very worthwhile doing this kind of thing. > It changes > our viewpoint of what is happening. For example, the jumping of > the initial > root functions is something of an artifact of algebra. It confuses > what is > really happening, say in a physical problem. When we take a global > view of > the solution set, the discontinuities lose their importantance. > What is more > important is that when the parameter a passes through a point that > produces > degenerate roots, then the solution set branches. If there is a > p'th order > root at the degeneracy, then there are p! branches to the solution > set. If a > physical solution corresponded to following a single root, then this > branching would certainly have significance - much more than the > discontinuities in the original root functions. And there is a lot of good mathematics that flowed out of visual and > graphical thinking. I'm sure I won't hear from Abbott who posed these particular > cases in > the first place. David Park > djmp@earthlink.net > http://home.earthlink.net/~djmp/ > One further (I hope last) comment. As usual I am unable to stick to this kind of promise ;-( In fact, it is clear that if we want to consider all roots of a > polynomial as a continuous function of the parameter we do not even > need to remove the discriminant. We can simply consider the map f: C^d -> S^d(C) where S^d(C) is the so called symmetric product on C (C stands for > the complex numbers). You can think of it as the space whose > elements > are unordered tuples (c1,c2,...,cd) of complex numbers - in other > words sets with d elements. So the map f assigns to a polynomial > x^d+ > a(d-1) x^(d-1)+...+a(0) the unordered tuple (a(d-1), a(d-2),..., a > (0)). The symmetric product has a natural topology (in fact the d-th > symmetric product on C happens to be homeomorphic to C^d but this is > not the case for other spaces, for example the d-th symetric product > on R is not R^d). Anyway, the map f is indeed a continuous map, and > this formalizes the statement that the set of roots of a complex > polynomial depends continuously on the coefficients. However, > this is > quite different from saying that you can define one continuous root > on the space of all polynomials, which is certainly impossible (see > again Adam Strzebonski's proof). I suspect this was the source of all the confusion here and we have > been arguing without understanding what the other side is talking > about. At least in my case this is the kind of situation that is > likely to lead to a loss of patience or even (as happened briefly > this time) temper. I think it also shows the great advantage of > using > formal mathematics rather than intuitive arguments, even if > supported > by very skillful animations. In 30 years of doing mathematics I > can't > recall coming across anyone loosing his temper over a strictly > formal > mathematical argument. When something like this does happen it > always > turns out that someone was simply not being formal enough. Andrzej Kozlowski > There is of course a sense in which the roots of a polynomial are >> continuous in the coefficients. Formally one has to use the concept >> of the symmetric product to state this. Let again X be the space >> C^d-S of monic polynomials of degree d with the determinant remove. >> Now we construct a space Y as follows. We first consider the >> subspace Z of the Cartesian product C^d, consisting of complex >> numbers (c_1,c_2,...,c_d) which are all distinct. The symmetric >> group on d elements (the permutation group) S(d) acts on Z, and we >> let Y be the set of orbits of the action Y=Z/S(d). So now we have a >> map f: X -> Y which assigns to a polynomial p in X, the unordered >> set of its roots (z_1,z_2,...,z_d). This map is certianly >> continuous with respect to the natural topologies on X and Y. >> Intuitively this says that the set of unordered roots (all of them) >> is indeed a continuous function of the parameters of the >> polynomials (but not the individual roots themselves). >> If, what you have been saying is in some way related to the above >> than of course I agree, but I can't see how this fact can in any >> way be useful in a computer program like Mathematica. >> Andrzej Kozlowski > I think I should have expressed myself differently. So here it is > again. I am sure that if you read and think about http://forums.wolfram.com/mathgroup/archive/2006/Dec/msg00496.html you will certianly know what I have been talking about. I don't > beleive you have done that. I can't explain it any better or > simpler. However, I can again state in a formal way what I am > asserting to be true. To talk of continuity of anything you have to specify three > things. One is a topological space X - the source space. The > second is a topological space Y - the target space. The third a > map (function) f: X -> Y. The statement of the theorem is: > Let X = C^d -S be the space of all complex monic polynomials with > the discriminant (the set of polynomials with a double root) > removed. Let Y = C (the complex numbers). Then there cannot exists > a continuous map f :X -> Y such that for any polynomial p in X, f > (p) is a root of p. This is proved by Adam Strzebonski in the above link. The theorem > of Vassiliev says that if d is a power of prime than you will need > at lead d open Sets U_1,U_2, ..., U_d whose union is all of X, > such that there is a map f_i: U_i -> C with the property that f(p) > is a root of p. I can also prove the following. Let X= R^d-S - the space of real > polynomials of degree d with the discriminant removed. Let Y=C. > Then there does exist a continuous map f: X -> Y such that for > each real polynomial p in X, f(p) is a root of p. (There are in > fact many such maps, exactly d over each connected component of > X). I think this is as clear as it can be made. Now, of course it is > quite possible that what you are trying to say is perfectly > sensible and correct. However, to make it mathematics you must be > able to make a formal statement like the above. An animation is > not a substitute for this. I have no idea form you animation what > is your X, what is your Y, and what is your function f that you > claim can be a continuous function. An animation or a graphic can > be useful once you only if they illustrate some formal mathematica > notions like these. Andrzej Kozlowski > As I already suggested: read >> http://forums.wolfram.com/mathgroup/archive/2006/Dec/ >> msg00496.html >> and then think about what it says. (Obviously the issue concernst >> each individual root being continuous). >> I think I have written about this as much as I am willing to do. >> Andrzej Kozlowski > Abbot asked: Again, ignoring root ordering, why > isn't it possible for all these roots to maintain their identity > and so > be continuous functions of the parameter? And wouldn't such > continuity > be nicer than enforcing root ordering? (I'm not certain if I exactly understand 's question. Does > he mean that > each individual root function, in the set of root functions, > must be > continuous, or does he allow global reindexing on the entire set > to achieve > continuity?) So, what exactly does your mathematical theorem say? Does it say > that given > a one-parameter finite order polynomial it is not possible to > continuously > reindex the set of root solutions so that the reindexed roots > will vary > continuously in the complex plane as a function of the > parameter? Or that > you can't do this when the polynomial contains a complex > coefficient? If it > says that, I don't believe it. It certainly is possible to arrange things so that the roots > vary > continuously, and it can even be useful. It reminds me of a Groucho Marx quip, something about: Are you > going to > listen to me or are you going to go by what you see in front of > your eyes? David Park > djmp@earthlink.net > http://home.earthlink.net/~djmp/ > I don't understand what you mean by continuous enough and > why you > think and animation can disprove a mathematical proof? Please read the argument: http://forums.wolfram.com/mathgroup/archive/2006/Dec/ > msg00496.html It is very simple. Remember the point is that you cannot define > such > a function that will be continuous over the entire 6 > dimensional (3 > complex dimensions) space of polynomials of degree 3 with > complex > roots (we actually normally remove the discriminant from the > space). > You are using a smaller subspace ( you have just one complex > parameter) and over a smaller subspace naturaly it is > possible to > have a continuous root. > If you look carefully at Adam's argument you will be easily > able to > see what must go wrong over the entire space of complex cubics. This in fact is a good illustration of what a double edged > weapon > graphics and animations are in studying mathematics: they can > just as > easily mislead your intuition and lead you to wrong conclusions > as to > right ones. Which is one reason why I think one should never > rely too > much on such tools when teaching mathematics. Proofs are > proofs and > no number of convincing animations and experimental > mathematics > can replace them. Andrzej Kozlowski, Department of Mathematics, Informatics and Mechanics > Warsaw University, Poland > This looks continuous enough to me, with and without complex >> coefficients. >> Needs[Graphics`Animation`] >> Needs[Graphics`Colors`] >> frame[a_] := >> Module[{roots = rootset[a], newroots, rootpermutations, >> distances, pick, >> locations}, >> rootpermutations = Permutations[roots]; >> distances = >> Plus @@ Abs[Part[roots, #] - memoryrootset] & /@ >> basepermutations; >> pick = Part[Position[distances, Min[distances], 1], 1, >> 1]; >> newroots = Part[roots, Part[basepermutations, pick]]]; >> memoryrootset = newroots; >> locations = {Re[#], Im[#]} & /@ newroots; >> Show[Graphics[ >> {LightCoral, AbsolutePointSize[15], >> Point /@ locations, >> Black, >> MapThread[Text[#1, #2] &, {Range[5], locations}], >> Text[SequenceForm[a = , >> NumberForm[a, {3, 2}, NumberPadding -> { , >> 0}]], >> Scaled[{0.1, 0.95}], {-1, 0}]}], >> AspectRatio -> Automatic, >> TextStyle -> {FontFamily -> Courier, FontSize -> 12, >> FontWeight -> Bold}, >> Frame -> True, >> PlotRange -> {{-3, 3}, {-3, 3}}, >> PlotLabel -> SequenceForm[Continuous Roots of , >> displaypoly], >> ImageSize -> 400] >> ] >> Case 1 >> polynomial = x^5 - a x - 1 == 0; >> displaypoly = polynomial /. a -> HoldForm[a]; >> rootset[a_] = x /. Solve[polynomial, x] >> memoryrootset = Null; >> basepermutations = Permutations[Range[5]]; >> Animate[frame[a], {a, -6, 10, 0.25}] >> SelectionMove[EvaluationNotebook[], All, GeneratedCell] >> FrontEndTokenExecute[OpenCloseGroup]; Pause[0.5]; >> FrontEndExecute[{FrontEnd`SelectionAnimate[200, >> AnimationDisplayTime -> 0.1, >> AnimationDirection -> ForwardBackward]}] >> Case 2 >> polynomial = x^5 + (1 + I) x^4 - a x - 1 == 0; >> displaypoly = polynomial /. a -> HoldForm[a]; >> rootset[a_] = x /. Solve[polynomial, x]; >> memoryrootset = Null; >> basepermutations = Permutations[Range[5]]; >> Animate[frame[a], {a, -6, 10, 0.5}] >> SelectionMove[EvaluationNotebook[], All, GeneratedCell] >> FrontEndTokenExecute[OpenCloseGroup]; Pause[0.5]; >> FrontEndExecute[{FrontEnd`SelectionAnimate[200, >> AnimationDisplayTime -> 0.1, >> AnimationDirection -> ForwardBackward]}] >> But this is a combinatoric algorithm and if there are too many >> roots it >> might begin to get costly. But it is perfectly practical for >> these >> examples. >> David Park >> djmp@earthlink.net >> http://home.earthlink.net/~djmp/ > What you describe, including the fact that the numbering or >> roots >> changes is inevitable and none of it is not a bug. There >> cannot >> exist >> an ordering of complex roots that does not suffer from this >> problem. >> What happens is this. >> Real root objects are ordered in the natural way. A cubic can >> have >> either three real roots or one real root and two conjugate >> complex >> ones. Let's assume we have the latter situation. Then the >> real root >> will be counted as being earlier then the complex ones. Now >> suppose >> you start changing the coefficients continuously. The roots >> will >> start moving in the complex plane, with the real root >> remaining on >> the real line the two complex roots always remaining >> conjugate >> (symmetric with respect to the real axis). Eventually they >> may >> collide and form a double real root. If this double real root >> is now >> smaller then the the original real root (actually than the >> root to >> which the original real root moved due the the changing of >> the >> parameter), there will be a jump in the ordering; the former >> root >> number 1 becoming number 3. >> This is completely unavoidable, not any kind of bug, and I am >> not >> complaining about it. It takes only elementary topology of >> configuration spaces to prove that this must always be so. But is there a continuous root numbering if the roots are not > ordered? What I mean is that if you compute the roots of a polynomial, > which > is a > function of a parameter, then if you assign a number to each > root, > can > you follow that root continuously as the parameter changes? > Two > examples > are presented below. Here is some code to animate numbered roots using the standard > root > ordering, displaying the root numbering: rootplot[r_] := Table[ListPlot[ > Transpose[{Re[x /. r[a]], Im[x /. r[a]]}], > PlotStyle -> AbsolutePointSize[10], > PlotRange -> {{-3, 3}, {-3, 3}}, > AspectRatio -> Automatic, > PlotLabel -> StringJoin[a=, ToString[PaddedForm[Chop > [a], {2, > 1}]]], > Epilog -> {GrayLevel[1], > MapIndexed[Text[#2[[1]], {Re[#1], Im[#1]}] & , x /. r > [a]]}], > {a, -6, 10, 0.5}] First, we have a polynomial with real coefficients: r1[a_] = Solve[x^5 - a x - 1 == 0, x] Animating the trajectories of the roots using rootplot[r1] we observe that, as you mention above, when the complex > conjugate > roots > 2 and 3 coalesce, they become real roots 1 and 2 and root 1 > becomes > root > 3. But, ignoring root ordering, why isn't it possible for > these > roots to > maintain their identity (I realise that at coelescence, there > is an > arbitrariness)? Second, we have a polynomial with a complex coefficient: r2[a_] = Solve[x^5 + (1+I) x^4 - a x - 1 == 0, x] Animating the trajectories of the roots using rootplot[r2] we observe that, even though the trajectories of the roots are > continuous, the numbering switches: 2 -> 3 -> 4 > 5 -> 4 -> 3 > 3 -> 4 -> 5 > 4 -> 3 -> 2 and only root 1 remains invariant. Again, ignoring root > ordering, why > isn't it possible for all these roots to maintain their > identity > and so > be continuous functions of the parameter? And wouldn't such > continuity > be nicer than enforcing root ordering? ______ > _ > __ > ____ > _ > _ > Abbott Phone: 61 8 > 6488 > 2734 > School of Physics, M013 Fax: +61 8 > 6488 > 1014 > The University of Western Australia (CRICOS > Provider No > 00126G) > AUSTRALIA http:// > physics.uwa.edu.au/ > ~ >> In the cases of polynomials with real coefficients it is indeed >> possible to define a continuous root. It is certianly not >> possible to >> do so for polynomials with complex coefficients. For a proof >> see my >> and Adam Strzebonski's posts in the same thread. Adam >> Strzebonski >> gave a very elementary proof of the fact that a continuous root >> cannot be defined on the space of complex polynomials of degree >> d. I >> quoted a more powerful but not elementary theorem of Vassiliev, >> which >> describes the minimum number of open sets that are needed to >> cover >> the space of complex polynomials of degree d, so that there >> is a >> continuous root defined on each open set. In fact, Vassiliev >> gives >> the exact number only in the case when d is prime, in which >> case d >> open sets are needed. For example, for polynomials of degree >> 3 at >> least 3 sets are needed . If it were possible to define a >> continuous >> root, then of course only one set would suffice. In the case >> when d >> is not prime no simple formula seems to be known, but it is >> easy to >> prove that that the number is >1, (e.g. by means of Adam >> Strzebonski's proof). >> Andrzej Kozlowski > > === Subject: Re: NIntegrate and the number of grid points used NIntegrate has the option EvaluationMonitor f[x_]:=Exp[x]*Sin[5x/2]; pts={};NIntegrate[f[x],{x,0,Pi},EvaluationMonitor:>AppendTo[pts, x]] 3.53665 Length[pts] 55 Plot[f[x],{x,0,Pi}, Epilog->{Red,Line[{{#,0},{#,f[#]}}]&/@pts},PlotRange->All,ImageSize->500]; Bob Hanlon > Hoi zame, I am using NIntegrate to run a few experiments. I wonder whether there is a > possibility to get access to the number of points used by Mathematica? That > would be helpful. Thomas === Subject: Re: normalize a table data={{1,0.2},{2,0.3},{3,0.4},{4,0.5}}; #/{Max[data[[All,1]]],1}&/@data {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} A different normalization (first terms sum to unity): #/{Total[data[[All,1]]],1}&/@data {{1/10, 0.2}, {1/5, 0.3}, {3/10, 0.4}, {2/5, 0.5}} Bob Hanlon I want to do something really simple, which is take a table made of > pairs and normalize the first number in each pair by dividing by the > largest. For instance, I want to transform this list {{1,0.2},{2,0.3},{3,0.4},{4,0.5}} into this one {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} The way i did it is through the chain of commands firsttable={{1,0.2},{2,0.3},{3,0.4},{4,0.5}}; > top=Max[Table[firsttable[[i,1]],{i,1,Length[firsttable]}]]; > mytable=Do[newtable=ReplacePart[newtable,newtable[[i,1]]/top,{i, > 1}],{i,1,Length[firsttable]}] There must be a more elegant way to do it, but @&# and commands like > those are still hard to handle for me, and I could not work it out > Ruth === Subject: Re: Series of LaguerreL problem These are the correct first few terms of the series expansion. The complete series is Sum[(-1)^m*FunctionExpand[LaguerreL[n-m,m,0]]*z^m/m!, {m,0,Infinity}]//FullSimplify LaguerreL[n,z] Bob Hanlon > Using 5.2 version and looking at the help browser on LaguerreL[] > function I see the following line In[1]:= > Series[LaguerreL[n, z], {z, 0, 4}] Out[1]:= > SeriesData[z, 0, {LaguerreL[n, 0], -LaguerreL[-1 + n, 1, 0], > LaguerreL[-2 + n, 2, 0]/2, -LaguerreL[-3 + n, 3, 0]/6, LaguerreL[-4 + n, > 4, 0]/24}, 0, 5, 1] Does it have any sense? Certainly, I can call FunctionExpand[] on the > Normal[%] The behaviour of version 5.0 was different and I suspect bug here. Explanation/motivation or bug confirmation would be wellcome. > -- > Arturas Acus === Subject: Re: a old post again > I assume you mean that Integrate's result is wrong and > NIntegrate's is right. Yes. Bhuvanesh. === Subject: General Mathematica and Financial Mathematics Courses CANdiensten offers general Mathematica and financial mathematics courses which might be of interest to you or your colleagues. The courses are offered at our training facilities in Amsterdam. Upcoming courses are: (1) Numerical Methods for Pricing Financial Derivatives February 14-15, 2007 - EURO 595 (excl. VAT) (2) Introduction to Mathematica 10.00-17.00 March 6, 2007 - EURO 95 (excl. VAT) (3) Programming with Mathematica April 10, 2007 - EURO 250 (excl. VAT) (4) Financial Modeling with Mathematica April 18-19, 2007 - EURO 595 (excl. VAT) (1) Numerical Methods for Pricing Financial Derivatives _________ February 14-15, 2007 - EURO 595 (excl. VAT) - Dr. Dimitri Neumann Apply and implement numerical methods to price financial derivatives. The rich functionality available within Mathematica allows to discuss different implementation approaches during the course and to analyze numerical issues arising from the presented methods. More information and on-line registration: http://www.can.nl/events/details.php?id=37 (2) Course: Introduction to Mathematica __ March 6, 2007 - EURO 95 (excl. VAT) - Prof. Fred Simons 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 (3) Course: Programming with Mathematica __ December 19, 2006 - EURO 250 (excl. VAT) - Prof. Fred Simons 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=20 (4) Financial Modeling with Mathematica _________ April 18-19, 2007 - EURO 595,- (excl. VAT) - Dr. Dimitri Neumann The course pays much attention to frequently occurring practical tasks such as getting common data structures into Mathematica and exact day calculations. More information and on-line registration: http://www.can.nl/events/details.php?id=36 Please let me know if you have any questions. Dick Verkerk SciFinance automated derivatives pricing software http://www.can.nl/software/details.php?id=2 ___________ 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: MathKernel crashes Hallo: MathKernel crashes, since I use recursive function for calculation. I have 2 of the important functions for my calculation as given below: $RecursionLimit=Infinity; pi[0, [Theta]_] := 0; pi[1, [Theta]_] := 1; pi[i_, [Theta]_] := pi[i, [Theta]] = ((2 i - 1)/(i - 1)) Cos[[Theta]] pi[i - 1, [Theta]] - (i/(i - 1)) pi[i - 2,[Theta]]); [Tau][i_, [Theta]_] := [Tau][i, [Theta]] = i Cos[[Theta]] pi[i, [Theta]] - (i + 1)pi[i - 1, [Theta]]; In this case, I can get solution to any numerical value like pi[14, [Pi]/3]. But quite a few times, it happened that MathKernel quitted, I started again, but it started another processor parallel to that. Later I wanted to calculate another function as follows: S1Temp[i_, [Theta]_] := ((2 l + 1)/(l (l + 1))) (an[l] pi[l, [Theta]] + bn[l] [Tau][l, [Theta]]); But in this case, whenever I try to calculate S1Temp[14, [Pi]/3], it simply quits and, sometimes crashes. I have to always restart Mathematica to start over again. I do not know what is exactly going wrong. If any better solution is possible for this recursive solution, will also be appreciated. nandan === Subject: Re: MathKernel crashes > Hallo: MathKernel crashes, since I use recursive function for calculation. I > have 2 of the important functions for my calculation as given below: > $RecursionLimit=Infinity; pi[0, [Theta]_] := 0; > pi[1, [Theta]_] := 1; > pi[i_, [Theta]_] := pi[i, [Theta]] = ((2 i - 1)/(i - 1)) > Cos[[Theta]] pi[i - 1, [Theta]] - (i/(i - 1)) pi[i - 2,[Theta]]); > [Tau][i_, [Theta]_] := [Tau][i, [Theta]] = i Cos[[Theta]] pi[i, > [Theta]] - (i + 1)pi[i - 1, [Theta]]; In this case, I can get solution to any numerical value like pi[14, > [Pi]/3]. But quite a few times, it happened that MathKernel quitted, I > started again, but it started another processor parallel to that. Later > I wanted to calculate another function as follows: > S1Temp[i_, [Theta]_] := ((2 l + 1)/(l (l + 1))) (an[l] pi[l, [Theta]] > + bn[l] [Tau][l, [Theta]]); But in this case, whenever I try to calculate S1Temp[14, [Pi]/3], it > simply quits and, sometimes crashes. I have to always restart > Mathematica to start over again. I do not know what is exactly going wrong. If any better solution is > possible for this recursive solution, will also be appreciated. nandan > Hi Nandan, why don't you simply use RSolve? Needs[DiscreteMath`RSolve`]; pi[i_, t_] = FullSimplify[p[i] /. First[RSolve[ {p[i] == ((2*i - 1)*Cos[t]*p[i - 1] - i*p[i - 2])/(i - 1), p[0] == 0, p[1] == 1}, p, i] ]] /. ((x_)^2)^(-2^(-1)) :> 1/Abs[x] --> -(LegendreP[i, 1, 2, Cos[t]]/Abs[Sin[t]]) pi[14, Pi/3] --> 30439185/8388608 === Subject: Re: MathKernel crashes Hi: I'm aware that these are recursive functions for this Legendre Polynomial, but they were taking lot of time, so I went for recursion. But in fact, it is take more time and my kernel quits. But I think, you have replied to this problem in this post: Thanx again! nandan Hallo: MathKernel crashes, since I use recursive function for calculation. I > have 2 of the important functions for my calculation as given below: > $RecursionLimit=Infinity; pi[0, [Theta]_] := 0; > pi[1, [Theta]_] := 1; > pi[i_, [Theta]_] := pi[i, [Theta]] = ((2 i - 1)/(i - 1)) > Cos[[Theta]] pi[i - 1, [Theta]] - (i/(i - 1)) pi[i - 2,[Theta]]); > [Tau][i_, [Theta]_] := [Tau][i, [Theta]] = i Cos[[Theta]] pi[i, > [Theta]] - (i + 1)pi[i - 1, [Theta]]; In this case, I can get solution to any numerical value like pi[14, > [Pi]/3]. But quite a few times, it happened that MathKernel quitted, I > started again, but it started another processor parallel to that. Later > I wanted to calculate another function as follows: > S1Temp[i_, [Theta]_] := ((2 l + 1)/(l (l + 1))) (an[l] pi[l, [Theta]] > + bn[l] [Tau][l, [Theta]]); But in this case, whenever I try to calculate S1Temp[14, [Pi]/3], it > simply quits and, sometimes crashes. I have to always restart > Mathematica to start over again. I do not know what is exactly going wrong. If any better solution is > possible for this recursive solution, will also be appreciated. nandan > Hi Nandan, why don't you simply use RSolve? Needs[DiscreteMath`RSolve`]; pi[i_, t_] = FullSimplify[p[i] /. > First[RSolve[ > {p[i] == ((2*i - 1)*Cos[t]*p[i - 1] - i*p[i - 2])/(i - 1), > p[0] == 0, p[1] == 1}, p, i] > ]] /. ((x_)^2)^(-2^(-1)) :> 1/Abs[x] --> -(LegendreP[i, 1, 2, Cos[t]]/Abs[Sin[t]]) pi[14, Pi/3] > --> 30439185/8388608 === Subject: Re: MathKernel crashes > Hallo: MathKernel crashes, since I use recursive function for calculation. I > have 2 of the important functions for my calculation as given below: > $RecursionLimit=Infinity; pi[0, [Theta]_] := 0; > pi[1, [Theta]_] := 1; > pi[i_, [Theta]_] := pi[i, [Theta]] = ((2 i - 1)/(i - 1)) -------------------^ Extra backslash must be removed > Cos[[Theta]] pi[i - 1, [Theta]] - (i/(i - 1)) pi[i - 2,[Theta]]); --------------------------------------------------------------------^ Extra parentheses must be removed > [Tau][i_, [Theta]_] := [Tau][i, [Theta]] = i Cos[[Theta]] pi[i, > [Theta]] - (i + 1)pi[i - 1, [Theta]]; Here is a corrected version of the code: In[1]:= pi[0, ëü_] = 0; pi[1, ëü_] = 1; pi[i_, ëü_] := pi[i, ëü] = ((2*i - 1)/(i - 1))*Cos[ëü]*pi[i - 1, ëü] - (i/(i - 1))*pi[i - 2, ëü]; ì.b3[i_, ëü_] := ì.b3[i, ëü] = i*Cos[ëü]*pi[i, ëü] - (i + 1)*pi[i - 1, ëü]; In[5]:= pi[14, Pi/3] Out[5]= 30439185 -------- 8388608 > In this case, I can get solution to any numerical value like pi[14, > [Pi]/3]. But quite a few times, it happened that MathKernel quitted,I It would have been nice that you provided an example of such a call. > started again, but it started another processor parallel to that. Later Not sure to understand what you mean: if the kernel really quits, you have no more kernel process loaded into memory. > I wanted to calculate another function as follows: > S1Temp[i_, [Theta]_] := ((2 l + 1)/(l (l + 1))) (an[l] pi[l, [Theta]] ---------^ Inconsistent syntax: i is never used in the code: do you mean l? At any rate, this definition will cause an infinite recursion whenever it is called. Increasing $RecursionLimit will do nothing. > + bn[l] [Tau][l, [Theta]]); But in this case, whenever I try to calculate S1Temp[14, [Pi]/3], it > simply quits and, sometimes crashes. I have to always restart > Mathematica to start over again. Here is a corrected version of the code: In[6]:= S1Temp[l_, ëü_] := ((2*l + 1)/(l*(l + 1)))* (an[l]*pi[l, ëü] + bn[l]*ì.b3[l, ëü]); In[7]:= S1Temp[14, Pi/3] Out[7]= 29 30439185 an[14] 115937115 bn[14] --- (--------------- - ----------------) 210 8388608 8388608 Now, the above result might or might not be what you expected since you did not provide any definition for an[i] and bn[i]. (Are they functions or arrays of values?) Jean-Marc === Subject: Re: MathKernel crashes Hi: On Jan 21, 11:22 am, Jean-Marc Gulliet have 2 of the important functions for my calculation as given below: > $RecursionLimit=Infinity; pi[0, [Theta]_] := 0; > pi[1, [Theta]_] := 1; > pi[i_, [Theta]_] := pi[i, [Theta]] = ((2 i - 1)/(i - 1))-------------------^ > Extra backslash must be removed Cos[[Theta]] pi[i - 1, [Theta]] - (i/(i - 1)) pi[i - 2,[Theta]]);--------------------------------------------------------------- -----^ > Extra parentheses must be removed [Tau][i_, [Theta]_] := [Tau][i, [Theta]] = i Cos[[Theta]] pi[i, > [Theta]] - (i + 1)pi[i - 1, [Theta]]; The syntax problem was due to wrong copying of the Mathematica code in StandardForm. Is there any better way of copying it in InputForm? > Here is a corrected version of the code: In[1]:= > pi[0, ëü_] = 0; > pi[1, ëü_] = 1; > pi[i_, ëü_] := pi[i, ëü] = > ((2*i - 1)/(i - 1))*Cos[ëü]*pi[i - 1, ëü] - > (i/(i - 1))*pi[i - 2, ëü]; > ì.b3[i_, ëü_] := ì.b3[i, ëü] = i*Cos[ëü]*pi[i, ëü] - > (i + 1)*pi[i - 1, ëü]; In[5]:= > pi[14, Pi/3] Out[5]= > 30439185 > -------- > 8388608 In this case, I can get solution to any numerical value like pi[14, > [Pi]/3]. But quite a few times, it happened that MathKernel quitted,IIt would have been nice that you provided an example of such a call. started again, but it started another processor parallel to that. LaterNot sure to understand what you mean: if the kernel really quits, you > have no more kernel process loaded into memory. The kernel simply quits, if the depth of recursion is big. The same problem has be observed by Johan and reported here: I wanted to calculate another function as follows: > S1Temp[i_, [Theta]_] := ((2 l + 1)/(l (l + 1))) (an[l] pi[l, [Theta]]---------^ > Inconsistent syntax: i is never used in the code: do you mean l? At any > rate, this definition will cause an infinite recursion whenever it is > called. Increasing $RecursionLimit will do nothing. I'm sorry, 'i' was meant for 'l'. Too many equations with different sums, makes it difficult to report. + bn[l] [Tau][l, [Theta]]); But in this case, whenever I try to calculate S1Temp[14, [Pi]/3], it > simply quits and, sometimes crashes. I have to always restart > Mathematica to start over again.Here is a corrected version of the code: In[6]:= > S1Temp[l_, ëü_] := ((2*l + 1)/(l*(l + 1)))* > (an[l]*pi[l, ëü] + bn[l]*ì.b3[l, ëü]); In[7]:= > S1Temp[14, Pi/3] Out[7]= > 29 30439185 an[14] 115937115 bn[14] > --- (--------------- - ----------------) > 210 8388608 8388608 Now, the above result might or might not be what you expected since you > did not provide any definition for an[i] and bn[i]. (Are they functions > or arrays of values?) The Solution for Pi/3 is faster, but in case of 'Pi/4' and higher 'l' it simply quits. I provide u the correct version of the code and also for a[i] and b[i], well, probably copying it as InputForm in Mathematica can give better understanding...: [Psi][l_, [Rho]_] := [Rho]*Sqrt[Pi/(2*[Rho])]*BesselJ[l + 1/2, [Rho]] [Psi]Prime[l_, [Rho]_] := Evaluate[D[[Psi][l, [Rho]], [Rho]]]; [Zeta][l_, [Rho]_] := [Psi][l, [Rho]] + I*[Rho]*Sqrt[Pi/(2*[Rho])]*BesselY[l + 1/2, [Rho]]; [Zeta]Prime[l_, [Rho]_] := Evaluate[D[[Zeta][l, [Rho]], [Rho]]]; In[81]:= an[l_] := Evaluate[(Subscript[m, 2]*[Psi]Prime[l, Subscript[s, 1][r]]*[Psi][l, Subscript[s, 2][r]] - Subscript[m, 1]*[Psi][l, Subscript[s, 1][r]]*[Psi]Prime[l, Subscript[s, 2][r]])/ (Subscript[m, 2]*[Zeta]Prime[l, Subscript[s, 1][r]]*[Psi][l, Subscript[s, 2][r]] - Subscript[m, 1]*[Zeta][l, Subscript[s, 1][r]]* [Psi]Prime[l, Subscript[s, 2][r]])] bn[l_] := Evaluate[(Subscript[m, 2]*[Psi][l, Subscript[s, 1][r]]*[Psi]Prime[l, Subscript[s, 2][r]] - Subscript[m, 1]*[Psi]Prime[l, Subscript[s, 1][r]]*[Psi][l, Subscript[s, 2][r]])/ (Subscript[m, 2]*[Zeta][l, Subscript[s, 1][r]]*[Psi]Prime[l, Subscript[s, 2][r]] - Subscript[m, 1]*[Zeta]Prime[l, Subscript[s, 1][r]]* [Psi][l, Subscript[s, 2][r]])] cn[l_] := Evaluate[(Subscript[m, 2]*[Zeta][l, Subscript[s, 1][r]]*[Psi]Prime[l, Subscript[s, 1][r]] - Subscript[m, 2]*[Zeta]Prime[l, Subscript[s, 1][r]]*[Psi][l, Subscript[s, 1][r]])/ (Subscript[m, 2]*[Zeta][l, Subscript[s, 1][r]]*[Psi]Prime[l, Subscript[s, 2][r]] - Subscript[m, 1]*[Zeta]Prime[l, Subscript[s, 1][r]]* [Psi][l, Subscript[s, 2][r]])] dn[l_] := Evaluate[(Subscript[m, 2]*[Zeta]Prime[l, Subscript[s, 1][r]]*[Psi][l, Subscript[s, 1][r]] - Subscript[m, 2]*[Zeta][l, Subscript[s, 1][r]]*[Psi]Prime[l, Subscript[s, 1][r]])/ (Subscript[m, 2]*[Zeta]Prime[l, Subscript[s, 1][r]]*[Psi][l, Subscript[s, 2][r]] - Subscript[m, 1]*[Zeta][l, Subscript[s, 1][r]]* [Psi]Prime[l, Subscript[s, 2][r]])] pi[0, [Theta]_] := 0; pi[1, [Theta]_] := 1; pi[i_, [Theta]_] := pi[i, [Theta]] = ((2*i - 1)/(i - 1))*Cos[[Theta]]*pi[i - 1, [Theta]] - (i/(i - 1))*pi[i - 2, [Theta]]; [Tau][i_, [Theta]_] := [Tau][i, [Theta]] = i*Cos[[Theta]]*pi[i, [Theta]] - (i + 1)*pi[i - 1, [Theta]]; S1[[Theta]_] := Sum[((2*l + 1)/(l*(l + 1)))*(an[l]*pi[l, [Theta]] + bn[l]*[Tau][l, [Theta]]), {l, 1, LastTerm[r]}]; S2[[Theta]_] := Sum[((2*l + 1)/(l*(l + 1)))*(an[l]*[Tau][l, [Theta]] + bn[l]*pi[l, [Theta]]), {l, 1, LastTerm[r]}]; Jean-Marc Thanx again! nandan === Subject: Dirac braket-formalism Hi! Is there a straightforward way to do simple operations in the braket-formalism with Mathematica? I stumbled across the New notation-Demo [1], but in Linux, Mathematica does not accept the angular brackets (in In[28]:=... of [1]). It marks them as missing closure (i.e. in a purple colour) and In[33]:= (of [1]) therefore returns Syntax::sntxb : Expression cannot beginn with a,:psi:|:phi: (:psi:,:phi: represented as greek letters). In this spirit Yours Gernot --- [1] http://documents.wolfram.com/v5/Demos/Notebooks/NewNotations.html === Subject: Better recursive method? Hallo: I have following recursive functions: pi(i, theta) := (2n-1)/(n-1) cos(theta) pi(i-1, theta) - n/(n-1) pi(i-2,theta) tau(i,theta) := n pi(i, theta) - (n+1) pi(i-1,theta) with intial values: pi(0,theta) := 0 pi(1,theta) := 1 These should calculate the following function: S1(theta) := sum(i=1-nstop) (2i+1)/(i(i+1)) (a(i) pi(i,theta) - b(i) tau(i,theta)) (where nstop=40) This should be pretty easy to calculate for Mathematica. I have written it the following way: pi[0,theta] := 0; pi[1,theta] := 1; pi[i_, theta_] := pi[i, theta] =(2n-1)/(n-1) Cos[theta] pi[i-1, theta] - n/(n-1) pi[i-2,theta] tau[i_,theta_] := n pi[i, theta] - (n+1) pi[i-1,theta] S1Temp[i_,theta_] := (2i+1)/(i(i+1)) (a[i] pi[i,theta] - b[i] tau[i,theta]) S1(theta) := Sum[ S1Temp[i,theta], {i, 1, nstop}] Well, it works fine, but it takes enormous time. I have introduced recursive function to save time for calculation of Legendre Polynomials of which the function 'pi' and 'tau' consist of. But the same function if I write with 2 loops each for 'theta' and 'i' in IDL, it calculates in fraction of a second. Even the simple calculation of 'pi[40,pi/4]' took more than 350 seconds. What could be the problem in my logic. Is there any other better way to write recursive functions in Mathematica? Any help will be appreciated! nandan === Subject: Re: Better recursive method? Hi nandan, I think the problem is that your pi() and tau() functions are evaluated analytically if you give analytic expressions for theta, and this takes large amounts of time. If you look at ByteCount[pi[i,PI/4]], this seems to grow exponentially with i, which is always a bad sign. Fix this by asking for S1[N[PI/4]] for instance, while n also is globally assigned a definite value. Roman. > Hallo: I have following recursive functions: > pi(i, theta) := (2n-1)/(n-1) cos(theta) pi(i-1, theta) - n/(n-1) > pi(i-2,theta) > tau(i,theta) := n pi(i, theta) - (n+1) pi(i-1,theta) with intial values: > pi(0,theta) := 0 > pi(1,theta) := 1 These should calculate the following function: > S1(theta) := sum(i=1-nstop) (2i+1)/(i(i+1)) (a(i) pi(i,theta) - b(i) > tau(i,theta)) (where nstop=40) This should be pretty easy to calculate for Mathematica. I have written > it the following way: > pi[0,theta] := 0; > pi[1,theta] := 1; > pi[i_, theta_] := pi[i, theta] =(2n-1)/(n-1) Cos[theta] pi[i-1, theta] > - n/(n-1) pi[i-2,theta] > tau[i_,theta_] := n pi[i, theta] - (n+1) pi[i-1,theta] > S1Temp[i_,theta_] := (2i+1)/(i(i+1)) (a[i] pi[i,theta] - b[i] > tau[i,theta]) > S1(theta) := Sum[ S1Temp[i,theta], {i, 1, nstop}] Well, it works fine, but it takes enormous time. I have introduced > recursive function to save time for calculation of Legendre Polynomials > of which the function 'pi' and 'tau' consist of. But the same function > if I write with 2 loops each for 'theta' and 'i' in IDL, it calculates > in fraction of a second. Even the simple calculation of 'pi[40,pi/4]' > took more than 350 seconds. What could be the problem in my logic. Is there any other better way to > write recursive functions in Mathematica? Any help will be appreciated! nandan === Subject: Re: Better recursive method? > Hallo: I have following recursive functions: > pi(i, theta) := (2n-1)/(n-1) cos(theta) pi(i-1, theta) - n/(n-1) > pi(i-2,theta) > tau(i,theta) := n pi(i, theta) - (n+1) pi(i-1,theta) with intial values: > pi(0,theta) := 0 > pi(1,theta) := 1 These should calculate the following function: > S1(theta) := sum(i=1-nstop) (2i+1)/(i(i+1)) (a(i) pi(i,theta) - b(i) > tau(i,theta)) (where nstop=40) This should be pretty easy to calculate for Mathematica. I have written > it the following way: > pi[0,theta] := 0; > pi[1,theta] := 1; -------^^^^^ Dubious syntax (will work only on specific cases): should be theta_ (with a Blank pattern matching.) > pi[i_, theta_] := pi[i, theta] =(2n-1)/(n-1) Cos[theta] pi[i-1, theta] > - n/(n-1) pi[i-2,theta] ----^ What is n? When Mathematica evaluates this expression on my system I get a recursion depth limit exceeded. > tau[i_,theta_] := n pi[i, theta] - (n+1) pi[i-1,theta] > S1Temp[i_,theta_] := (2i+1)/(i(i+1)) (a[i] pi[i,theta] - b[i] > tau[i,theta]) > S1(theta) := Sum[ S1Temp[i,theta], {i, 1, nstop}] ----^-----^ Wrong syntax: could you please post the actual working code? > Well, it works fine, but it takes enormous time. I have introduced > recursive function to save time for calculation of Legendre Polynomials > of which the function 'pi' and 'tau' consist of. But the same function > if I write with 2 loops each for 'theta' and 'i' in IDL, it calculates > in fraction of a second. Even the simple calculation of 'pi[40,pi/4]' You are using exact arithmetic (infinite precision managed by software.) This is the most precise arithmetic mmodel, but also the slowest. Try pi[40.0,Pi/4] to use machine precision numbers. Jean-Marc > took more than 350 seconds. What could be the problem in my logic. Is there any other better way to > write recursive functions in Mathematica? Any help will be appreciated! nandan > === Subject: Re: Better recursive method? nandan skrev: > This should be pretty easy to calculate for Mathematica. I have written > it the following way: > pi[0,theta] := 0; > pi[1,theta] := 1; I believe this should be pi[0,theta_] := 0 > pi[i_, theta_] := pi[i, theta] =(2n-1)/(n-1) Cos[theta] pi[i-1, theta] > - n/(n-1) pi[i-2,theta] Here n is a free variable, and I get a huge expression when trying to evaluate this. Is it correct to guess that n should be i? I also believe that in general it is best to add an N[...] in the definition of pi, to avoid a large polynomial expression in rational numbers and Cos[theta]. If that is the case, and after setting $RecursionLimit = Infinity, it My kernel quits silently when attempting pi[10000,1], and I would be interested in knowing why. > in IDL, it calculates > in fraction of a second. Even the simple calculation of 'pi[40,pi/4]' > took more than 350 seconds. What could be the problem in my logic. Is there any other better way to > write recursive functions in Mathematica? > I believe it is about avoiding analytical expressions when you only want numerical answers. Hope this can help somewhat. / johan === Subject: Re: Better recursive method? > This should be pretty easy to calculate for Mathematica. I have written > it the following way: > pi[0,theta] := 0; > pi[1,theta] := 1; These should probably be theta_ instead of theta. > pi[i_, theta_] := pi[i, theta] =(2n-1)/(n-1) Cos[theta] pi[i-1, theta] > - n/(n-1) pi[i-2,theta] > tau[i_,theta_] := n pi[i, theta] - (n+1) pi[i-1,theta] > S1Temp[i_,theta_] := (2i+1)/(i(i+1)) (a[i] pi[i,theta] - b[i] > tau[i,theta]) > S1(theta) := Sum[ S1Temp[i,theta], {i, 1, nstop}] Well, it works fine, but it takes enormous time. Can you give an example of a computation that takes a long time? Do you want a symbolic answer in terms of n and/or theta? > I have introduced > recursive function to save time for calculation of Legendre Polynomials > of which the function 'pi' and 'tau' consist of. But the same function > if I write with 2 loops each for 'theta' and 'i' in IDL, it calculates > in fraction of a second. Even the simple calculation of 'pi[40,pi/4]' > took more than 350 seconds. With the above fix that takes 0.000077s here. -- Dr Jon D Harrop, Flying Frog Consultancy http://www.ffconsultancy.com/products/ocaml_for_scientists/index.html?usenet === Subject: Re: Better recursive method? and transform the recursion into and iteration doesn not help ? and using pi[0,_] := 0; pi[1,_] := 1; pi[i_, theta_] := pi[i, theta] =(2n-1)/(n-1) Cos[theta] pi[i-1, theta] - n/(n-1) pi[i-2,theta] would be the first step and pi[n_, theta_] := Module[{p1,p2}, p1=0; p2=1; Do[ p1=p2*(2i-1)/(i-1) Cos[theta] - i/(i-1) p1; tmp=p2; p2=p1; p1=tmp,{i,2,n}] p2 ] the second one ... BTW why do you use i in the patteren and n in the recursion ?? Jens > Hallo: I have following recursive functions: > pi(i, theta) := (2n-1)/(n-1) cos(theta) pi(i-1, theta) - n/(n-1) > pi(i-2,theta) > tau(i,theta) := n pi(i, theta) - (n+1) pi(i-1,theta) with intial values: > pi(0,theta) := 0 > pi(1,theta) := 1 These should calculate the following function: > S1(theta) := sum(i=1-nstop) (2i+1)/(i(i+1)) (a(i) pi(i,theta) - b(i) > tau(i,theta)) (where nstop=40) This should be pretty easy to calculate for Mathematica. I have written > it the following way: > pi[0,theta] := 0; > pi[1,theta] := 1; > pi[i_, theta_] := pi[i, theta] =(2n-1)/(n-1) Cos[theta] pi[i-1, theta] > - n/(n-1) pi[i-2,theta] > tau[i_,theta_] := n pi[i, theta] - (n+1) pi[i-1,theta] > S1Temp[i_,theta_] := (2i+1)/(i(i+1)) (a[i] pi[i,theta] - b[i] > tau[i,theta]) > S1(theta) := Sum[ S1Temp[i,theta], {i, 1, nstop}] Well, it works fine, but it takes enormous time. I have introduced > recursive function to save time for calculation of Legendre Polynomials > of which the function 'pi' and 'tau' consist of. But the same function > if I write with 2 loops each for 'theta' and 'i' in IDL, it calculates > in fraction of a second. Even the simple calculation of 'pi[40,pi/4]' > took more than 350 seconds. What could be the problem in my logic. Is there any other better way to > write recursive functions in Mathematica? Any help will be appreciated! nandan > === Subject: Help with plotting and iterations Hello All, Need help in working with Mathematica to determine (result_aa, result_bb) values over a range of variable p. p = 0.01; a = 0.5; b = 0.25; h = 0.25; m = b/a; m1 = Sqrt[1-m m]; z = (p-i h)/b; (z is complex and (i h) represents imaginary part) t = ArcSin[z]; t1 = Re[t]; t2 = -Im[t]; b1 = Cot[t1]^2 + m^2*Sinh[t2]-m1; c = m1^2*Cot[t1]^2; Solve[x^2 - b1*x - c,x]; x = x/. % x = Last[x]; {i need the positive root from the two} aa = ArcCot[Sqrt[x]]; bb = Arctan[Sqrt[x/m1]]; Faa = EllipticF[aa,m]; Fbb = EllipticF[bb,m1]; result_aa(count) = Faa; result_bb(count) = Fbb; count = count+1 I would like to determine the values of Faa and Fbb over a range of p = 0.01 to 10 with increments of 0.01 till 1.0 and then an increment of 1, that is [0.01:0.01:1 2:1:10] Finally, I would like to plot with result_aa along x-axis and result_bb along y-axis. Hope some one can solve the above problem. Ashesh === Subject: Re: Help with plotting and iterations > Hello All, Need help in working with Mathematica to determine (result_aa, > result_bb) values over a range of variable p. p = 0.01; a = 0.5; b = 0.25; h = 0.25; > m = b/a; > m1 = Sqrt[1-m m]; > z = (p-i h)/b; (z is complex and (i h) represents imaginary part) ---------^ Sqrt[-1] is capital i (I) in Mathematica syntax > t = ArcSin[z]; > t1 = Re[t]; > t2 = -Im[t]; > b1 = Cot[t1]^2 + m^2*Sinh[t2]-m1; > c = m1^2*Cot[t1]^2; > Solve[x^2 - b1*x - c,x]; ----------------------^ The expression is incomplete: an equal sign, followed by a quantity. > x = x/. % > x = Last[x]; {i need the positive root from the two} > aa = ArcCot[Sqrt[x]]; > bb = Arctan[Sqrt[x/m1]]; > Faa = EllipticF[aa,m]; > Fbb = EllipticF[bb,m1]; result_aa(count) = Faa; > result_bb(count) = Fbb; > count = count+1 I would like to determine the values of Faa and Fbb over a range of p = > 0.01 to 10 with increments of 0.01 till 1.0 and then an increment of 1, > that is [0.01:0.01:1 2:1:10] Finally, I would like to plot with result_aa along x-axis and result_bb > along y-axis. Hope some one can solve the above problem. Ashesh > Hi Ashesh, A quick and dirty approach could be the following In[1]:= resAA[a_, b_, h_][start_, end_, inc_] := Module[{m = b/a, m1}, m1 = Sqrt[1 - m*m]; Table[EllipticF[ArcCot[ Sqrt[Last[x /. Solve[ x^2 - (Cot[Re[ArcSin[(p - I*h)/b]]]^2 + m^2* Sinh[-Im[ArcSin[(p - I*h)/b]]] - m1)*x - m1^2*Cot[Re[ArcSin[(p - I*h)/b]]]^2 == 0, x]]]], m], {p, start, end, inc}]] resBB[a_, b_, h_][start_, end_, inc_] := Module[{m = b/a, m1}, m1 = Sqrt[1 - m*m]; Table[EllipticF[ArcCot[(1/m1)* Sqrt[Last[x /. Solve[ x^2 - (Cot[Re[ArcSin[(p - I*h)/b]]]^2 + m^2*Sinh[-Im[ArcSin[(p - I*h)/b]]] - m1)* x - m1^2*Cot[Re[ArcSin[(p - I*h)/b]]]^2 == 0, x]]]], m1], {p, start, end, inc}]] resAA[0.5, 0.25, 0.25][0.01, 1, 1/100] resAA[0.5, 0.25, 0.25][2, 10, 1] resBB[0.5, 0.25, 0.25][0.01, 1, 1/100] resBB[0.5, 0.25, 0.25][2, 10, 1] ListPlot[Transpose[{Join[resAA[0.5, 0.25, 0.25][0.01, 1, 1/100], resAA[0.5, 0.25, 0.25][2, 10, 1]], Join[resBB[0.5, 0.25, 0.25][0.01, 1, 1/100], resBB[0.5, 0.25, 0.25][2, 10, 1]]}]]; Out[3]= {0.0282828,0.0565564,0.0848114,0.113038,0.141226,0.169363,0.197438,0.225436, 0. 253343,0.281141,0.308811,0.336334,0.363688,0.390847,0.417787,0.44448,0.47089 7, 0.497007,0.52278,0.548184,0.573186,0.597756,0.621862,0.645475,0.668567,0. 691112,0.713088,0.734473,0.755252,0.77541,0.794938,0.813827,0.832075,0.84968 , 0.866646,0.882977,0.898681,0.913767,0.928246,0.942131,0.955437,0.968176,0. 980366,0.992021,1.00316,1.01379,1.02394,1.03362,1.04285,1.05163,1.05999,1. 06794,1.07549,1.08266,1.08946,1.0959,1.10199,1.10774,1.11316,1.11827,1.12308 , 1.12758,1.13179,1.13572,1.13937,1.14276,1.14588,1.14875,1.15136,1.15373,1. 15587,1.15777,1.15943,1.16088,1.1621,1.1631,1.1639,1.16448,1.16486,1.16504,1 . 16501,1.1648,1.16439,1.1638,1.16302,1.16206,1.16093,1.15962,1.15815,1.15651, 1. 15471,1.15276,1.15065,1.1484,1.146,1.14347,1.1408,1.13801,1.13509,1.13206} Out[4]= {0.783389,0.617285,0.525222,0.464934,0.421559,0.38843,0.36206,0.340423,0. 322255} Out[5]= {0.0244957,0.0489962,0.0735061,0.0980294,0.12257,0.14713,0.171711,0.196312,0 . 220934,0.245572,0.270222,0.294876,0.319525,0.344156,0.368756,0.393308,0. 417792,0.442186,0.466466,0.490607,0.51458,0.538355,0.561903,0.585192,0.60819 1, 0.630869,0.653197,0.675145,0.696686,0.717796,0.738453,0.758635,0.778326,0. 797512,0.81618,0.834322,0.85193,0.869002,0.885534,0.901528,0.916984,0.931907 , 0.946301,0.960172,0.973528,0.986375,0.998722,1.01058,1.02195,1.03285,1.04329 , 1.05327,1.0628,1.0719,1.08058,1.08883,1.09668,1.10412,1.11117,1.11784,1.1241 2, 1.13004,1.1356,1.14079,1.14564,1.15014,1.1543,1.15814,1.16164,1.16483,1.1676 9, 1.17025,1.1725,1.17445,1.1761,1.17746,1.17853,1.17932,1.17984,1.18008,1.1800 5, 1.17975,1.1792,1.1784,1.17735,1.17605,1.17452,1.17276,1.17077,1.16856,1.1661 4, 1.16351,1.16069,1.15767,1.15447,1.15109,1.14754,1.14383,1.13996,1.13595} Out[6]= {0.726211,0.557415,0.468778,0.412248,0.372214,0.341958,0.318053,0.298551,0. 282246} <... graphics deleted ...> HTH, Jean-Marc === Subject: Re: Help with plotting and iterations I got a reply to the above problem by Bob and it works excellently... Here is the solution: result[p_]:=Module[{a=1/2,b=1/4,h=1/4, m,m1,z,t,t1,t2,b1,c,x,aa,bb}, m=b/a; m1=Sqrt[1-m^2]; z=(p-I*h); t=ArcSin[z]; t1=Re[t]; t2=-Im[t]; b1=Cot[t1]^2+m^2*Sinh[t2]-m1; c=m1^2*Cot[t1]^2; x=Reduce[{x^2 - b1*x - c==0,x>=0},x]// Last//N; aa=ArcCot[Sqrt[x]]; bb=ArcTan[Sqrt[x/m1]]; {EllipticF[aa,m],EllipticF[bb,m1]}]; TableForm[Join[ Table[Prepend[result[p],p],{p,0.01,0.99,0.01}], Table[Prepend[result[p],p],{p,1,10}]], TableHeadings->{None,{p,Faa,Fbb}}] ParametricPlot[result[p], {p, 0.01, Pi}, AxesLabel->{Faa,Fbb},ImageSize->432]; Ashesh === Subject: Re: normalize a table >I want to do something really simple, which is take a table made of >pairs and normalize the first number in each pair by dividing by the >largest. >For instance, I want to transform this list >{{1,0.2},{2,0.3},{3,0.4},{4,0.5}} >into this one >{{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} >The way i did it is through the chain of commands First, getting the divisor can be done as In[2]:= data={{1,0.2},{2,0.3},{3,0.4},{4,0.5}}; In[3]:= scale=Max[First/@data] Out[3]= 4 then, the desired result can be achieved with pattern matching as: In[4]:= data/.{a_,b_}->{a/scale,b} Out[4]= {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} or functional programming as In[5]:= {First@#/scale,Last@#}&/@data Out[5]= {{1/4, 0.2}, {1/2, 0.3}, {3/4, 0.4}, {1, 0.5}} -- To reply via email subtract one hundred and four === Subject: Wolfram Workbench: SVN & notebook diffs tool for Wolfram Workbench, that used the front end to do diffs of -- http://chris.chiasson.name/ === Subject: Re: Warning: Actions not found: delete-next-character > Every time I run Mathematica 5.2 on SuSe10.1/x86-64 I get a stderr > window filled up with: Warning: Actions not found: delete-next-character > ... > Warning: Actions not found: delete-next-character Is there a fix for this warning? > Hi Ted, The following FAQ should help, How do I prevent delete-next-character warning messages when running Mathematica 5.x under the SuSE Linux 9.2 and 10 (64-bit) distributions? http://support.wolfram.com/mathematica/systems/linux/intel/deletenext51.html HTH, Jean-Marc === Subject: Re: Help with plotting and iterations result[p_]:=Module[{a=1/2,b=1/4,h=1/4, m,m1,z,t,t1,t2,b1,c,x,aa,bb}, m=b/a; m1=Sqrt[1-m^2]; z=(p-I*h); t=ArcSin[z]; t1=Re[t]; t2=-Im[t]; b1=Cot[t1]^2+m^2*Sinh[t2]-m1; c=m1^2*Cot[t1]^2; x=Reduce[{x^2 - b1*x - c==0,x>=0},x]// Last//N; aa=ArcCot[Sqrt[x]]; bb=ArcTan[Sqrt[x/m1]]; {EllipticF[aa,m],EllipticF[bb,m1]}]; TableForm[Join[ Table[Prepend[result[p],p],{p,0.01,0.99,0.01}], Table[Prepend[result[p],p],{p,1,10}]], TableHeadings->{None,{p,Faa,Fbb}}] ParametricPlot[result[p], {p, 0.01, Pi}, AxesLabel->{Faa,Fbb},ImageSize->432]; Bob Hanlon Hello All, Need help in working with Mathematica to determine (result_aa, > result_bb) values over a range of variable p. p = 0.01; a = 0.5; b = 0.25; h = 0.25; > m = b/a; > m1 = Sqrt[1-m m]; > z = (p-i h)/b; (z is complex and (i h) represents imaginary part) > t = ArcSin[z]; > t1 = Re[t]; > t2 = -Im[t]; > b1 = Cot[t1]^2 + m^2*Sinh[t2]-m1; > c = m1^2*Cot[t1]^2; > Solve[x^2 - b1*x - c,x]; > x = x/. % > x = Last[x]; {i need the positive root from the two} > aa = ArcCot[Sqrt[x]]; > bb = Arctan[Sqrt[x/m1]]; > Faa = EllipticF[aa,m]; > Fbb = EllipticF[bb,m1]; result_aa(count) = Faa; > result_bb(count) = Fbb; > count = count+1 I would like to determine the values of Faa and Fbb over a range of p = > 0.01 to 10 with increments of 0.01 till 1.0 and then an increment of 1, > that is [0.01:0.01:1 2:1:10] Finally, I would like to plot with result_aa along x-axis and result_bb > along y-axis. Hope some one can solve the above problem. Ashesh > === Subject: Re: how to quickly read a >10MB big file >file size is >10MB. Using mathematica 5, it takes over 30 mins to read >the data in; but using fortran, it takes only several secs. Does anyone >has a good idea to read such a file quickly. For anyone to be of any real help, you need to provide some details about how the file is structured and what you are doing to read it in with Mathematica. Mathematica is capable of reading large files in reasonable times. For example, using Mathematica 5.2 on a Mac with a 1.6 GHz processor, I am able to read a file of 1.3 million lines (80 MB) in ~20 seconds. -- To reply via email subtract one hundred and four === Subject: Re: Better recursive method? > Hallo: I have following recursive functions: > pi(i, theta) := (2n-1)/(n-1) cos(theta) pi(i-1, theta) - n/(n-1) > pi(i-2,theta) > tau(i,theta) := n pi(i, theta) - (n+1) pi(i-1,theta) with intial values: > pi(0,theta) := 0 > pi(1,theta) := 1 These should calculate the following function: > S1(theta) := sum(i=1-nstop) (2i+1)/(i(i+1)) (a(i) pi(i,theta) - b(i) > tau(i,theta)) (where nstop=40) This should be pretty easy to calculate for Mathematica. I have written > it the following way: > pi[0,theta] := 0; > pi[1,theta] := 1; > pi[i_, theta_] := pi[i, theta] =(2n-1)/(n-1) Cos[theta] pi[i-1, theta] > - n/(n-1) pi[i-2,theta] > tau[i_,theta_] := n pi[i, theta] - (n+1) pi[i-1,theta] > S1Temp[i_,theta_] := (2i+1)/(i(i+1)) (a[i] pi[i,theta] - b[i] > tau[i,theta]) > S1(theta) := Sum[ S1Temp[i,theta], {i, 1, nstop}] Well, it works fine, but it takes enormous time. I have introduced > recursive function to save time for calculation of Legendre Polynomials > of which the function 'pi' and 'tau' consist of. But the same function > if I write with 2 loops each for 'theta' and 'i' in IDL, it calculates > in fraction of a second. Even the simple calculation of 'pi[40,pi/4]' > took more than 350 seconds. What could be the problem in my logic. Is there any other better way to > write recursive functions in Mathematica? Any help will be appreciated! nandan > It looks generally reasonable to me. What hits hard is the complexity growth in i. For the example at hand it can be reduced considerably with Together. pi[i_, t_] := pi[i, t] = Together[(2*n - 1)/(n - 1)*Cos[t]*pi[i - 1, t] - n/(n + 1)*pi[i - 2, t]] This cuts the computation time considerably. In[44]:= Timing[ss=S1[Pi/4];] Out[44]= {0.344 Second,Null} Another possibility is to find a closed form for pi[] using RSolve. In[49]:=InputForm[ RSolve[{p2[i]==(2*n-1)/(n-1)*Cos[t]*p2[i-1]-n/(n+1)*p2[i-2], p2[0][Equal]0,p2[1][Equal]1},p2[i],i]] Out[49]//InputForm= {{p2[i] -> -(((-1 + n^2)*(((-Cos[t] + n*Cos[t] + 2*n^2*Cos[t] - Sqrt[-4*(-1 + n^2)*(-n + n^2) + (Cos[t] - n*Cos[t] - 2*n^2*Cos[t])^2])/(-1 + n^2))^i - ((-Cos[t] + n*Cos[t] + 2*n^2*Cos[t] + Sqrt[-4*(-1 + n^2)*(-n + n^2) + (Cos[t] - n*Cos[t] - 2*n^2*Cos[t])^2])/(-1 + n^2))^i))/ (2^i*Sqrt[-4*(-1 + n^2)*(-n + n^2) + (Cos[t] - n*Cos[t] - 2*n^2*Cos[t])^2]))}} This can now be used to construct your sum. Daniel Lichtblau Wolfram Research === Subject: Re: Better recursive method? Use Simplify in the definition of pi to keep the complexity of the expression from growing unnecessarily Clear[n,pi]; pi[0,theta_]:=0; pi[1,theta_]:=1; pi[i_,theta_]:=pi[i,theta]=Simplify[ (2n-1)/(n-1) Cos[theta] pi[i-1,theta]-n/(n-1) pi[i-2,theta]]; pi[40,Pi/4]//Timing {4.7574130000000014*Second, (1/(524288*Sqrt[2]*(-1 + n)^39))*(-1 + 2*n + 72*n^2 - 288*n^3 - 1816*n^4 + 12912*n^5 + 5376*n^6 - 251904*n^7 + 598656*n^8 + 1706752*n^9 - 11354112*n^10 + 13246464*n^11 + 63092224*n^12 - 263689216*n^13 + 253989888*n^14 + 911228928*n^15 - 3580728576*n^16 + 4528556544*n^17 + 3750897664*n^18 - 25007235072*n^19 + 45057976320*n^20 - 30315253760*n^21 - 44281528320*n^22 + 155489402880*n^23 - 228225269760*n^24 + 190602706944*n^25 - 41819701248*n^26 - 138994515968*n^27 + 255847432192*n^28 - 267452153856*n^29 + 202105159680*n^30 - 117021081600*n^31 + 52585758720*n^32 - 18160680960*n^33 + 4679270400*n^34 - 849346560*n^35 + 96993280*n^36 - 5242880*n^37)} Bob Hanlon > Hallo: I have following recursive functions: > pi(i, theta) := (2n-1)/(n-1) cos(theta) pi(i-1, theta) - n/(n-1) > pi(i-2,theta) > tau(i,theta) := n pi(i, theta) - (n+1) pi(i-1,theta) with intial values: > pi(0,theta) := 0 > pi(1,theta) := 1 These should calculate the following function: > S1(theta) := sum(i=1-nstop) (2i+1)/(i(i+1)) (a(i) pi(i,theta) - b(i) > tau(i,theta)) (where nstop=40) This should be pretty easy to calculate for Mathematica. I have written > it the following way: > pi[0,theta] := 0; > pi[1,theta] := 1; > pi[i_, theta_] := pi[i, theta] =(2n-1)/(n-1) Cos[theta] pi[i-1, theta] > - n/(n-1) pi[i-2,theta] > tau[i_,theta_] := n pi[i, theta] - (n+1) pi[i-1,theta] > S1Temp[i_,theta_] := (2i+1)/(i(i+1)) (a[i] pi[i,theta] - b[i] > tau[i,theta]) > S1(theta) := Sum[ S1Temp[i,theta], {i, 1, nstop}] Well, it works fine, but it takes enormous time. I have introduced > recursive function to save time for calculation of Legendre Polynomials > of which the function 'pi' and 'tau' consist of. But the same function > if I write with 2 loops each for 'theta' and 'i' in IDL, it calculates > in fraction of a second. Even the simple calculation of 'pi[40,pi/4]' > took more than 350 seconds. What could be the problem in my logic. Is there any other better way to > write recursive functions in Mathematica? Any help will be appreciated! nandan > -- === Subject: simple equation manipulation Hi I have: ( (a - 6k^2(c+b)) / k^2) I want: a/k^2 - 6(c+b) Using mathematica, what command does this? Andrew === Subject: Re: simple equation manipulation Hi Andrew, try e.g.: Apart Daniel > Hi I have: > ( (a - 6k^2(c+b)) > / k^2) I want: > a/k^2 - 6(c+b) > Using mathematica, what command does this? Andrew > === Subject: Re: simple equation manipulation > Hi I have: > ( (a - 6k^2(c+b)) > / k^2) I want: > a/k^2 - 6(c+b) > Using mathematica, what command does this? Andrew > Hi! Apart Peter ;-) === Subject: Re: simple equation manipulation > Hi I have: > ( (a - 6k^2(c+b)) > / k^2) I want: > a/k^2 - 6(c+b) > Using mathematica, what command does this? Andrew > In[1]:= Apart@((a-6k^2(c+b))/k^2)//TraditionalForm Out[1]//TraditionalForm= a -- - 6 (b + c) 2 k Jean-Marc === Subject: Re: how to quickly read a >10MB big file What does a typical line of data from your file look like? What command are you using to import the data? > It is a file which has nearly 100,000 data lines. The file size is -- http://chris.chiasson.name/ === Subject: Re: how to quickly read a >10MB big file Depends on what you're doing with the file. I've found that the Import function is as fast as my Fortran. It's so fast for parsing numbers, that I've written functions that read a big file, remove all the extraneous lines of text, rewrite to disk, then Import as a table. That's much faster than anything I can write that parses line-by-line. G. Flanagan > It is a file which has nearly 100,000 data lines. The file size is > >> > === Subject: RE: how to quickly read a >10MB big file > It is a file which has nearly 100,000 data lines. The file size is >10MB. Using mathematica 5, it takes over 30 mins to read the > data in; but using fortran, it takes only several secs. Does > anyone has a good idea to read such a file quickly. Many How are you reading the file into Mathematica? Read? ReadList? Import? The MathGroup package FastBinary? Are you reading the file, then processing it, or processing it as you go? All these factors will have a bearing on the speed that you can read your data into Mathematica. In addition, while Fortran can be quite a bit quicker than Mathematica, are you sure it's a fair comparison between the two? Please tell the list a bit more about how you're working. Posting code and a sample of the data you're working with will probably get quicker, more appropriate answers than not. Dave. === Subject: Re: how to quickly read a >10MB big file Sorry, I forgot to tell you the details. Let me give them now. The format of the file is that five note lines followed by a block of data (6 columns * 100000 lines). It looks like as below: ---------------------------------------------------------------------------- ------------------------- The file was generated on Jan-01-2007 ParameterA=0.20998977 ParameterB=-2323.898780 ParameterC=1223 the full output is: -7.9777019460E-03 5.8979296313E-03 -5.8992690654E-02 -1.9555038170E-03 -0.2143438800 0.9835566699 9.5788225640E-02 -1.6666155312E-02 -2.3570413269E-02 8.4937134986E-04 -0.1289696421 0.9813171342 6.7266728621E-02 -2.7685295289E-02 4.8717250310E-02 1.5101454940E-02 -0.1758737132 0.9917945596 ... ... ... ---------------------------------------------------------------------------- ------------------------- My PC has a Pentium4 CPU and 512MB memory. I have used Import (using type Table), ReadList and FindList, but all of them were very slow. Looking forward to your help! PW It is a file which has nearly 100,000 data lines. The file size is >10MB. Using mathematica 5, it takes over 30 mins to read the > data in; but using fortran, it takes only several secs. Does > anyone has a good idea to read such a file quickly. Many How are you reading the file into Mathematica? Read? ReadList? Import? > The MathGroup package FastBinary? Are you reading the file, then processing > it, or processing it as you go? All these factors will have a bearing on the speed that you can read your > data into Mathematica. In addition, while Fortran can be quite a bit > quicker than Mathematica, are you sure it's a fair comparison between the > two? Please tell the list a bit more about how you're working. Posting code and > a sample of the data you're working with will probably get quicker, more > appropriate answers than not. > Dave. === Subject: how to quickly read a >10MB big file It is a file which has nearly 100,000 data lines. The file size is === Subject: Re: how to quickly read a >10MB big file It is a file which has nearly 100,000 data lines. The file size is larger than 10MB. Using mathematica 5, it takes over 30 mins to read the data in; but using fortran, it takes only several secs. Does anyone in advance! === Subject: Re: how to quickly read a >10MB big file > It is a file which has nearly 100,000 data lines. The file size is > Mathematica is no magic. It would have greatly help answering your question if you had bother to provide some details about your data file: Is it 10^5 lines of numbers? In what format (scientific, raw digits,...)? Are there any nested structures? Any character strings? ...? Moreover, what Mathematica command have you used? (Import, Read, BinaryRead,...) Jean-Marc === Subject: Kernel Quits without error message. (Was: Better recursive method?) When trying to modify the example given by nandan, I arrive at a short function that makes the Kernel quit without displaying any error or warning message. With the definition pi[0, theta_] := 0; pi[1, theta_] := 1; pi[i_, theta_] := pi[i, theta] = N[(2i - 1)/(i - 1) Cos[theta] pi[i - 1, theta] - i/(i - 1) * pi[i - 2, theta]] and a high value for $RecursionLimit, I can evaluate pi[1000,1] in about 0.06 seconds but the kernel quits when attempting pi[10000,1]. There is neither warning nor error, and I see the same behaviour several times. I have seen this both in my student version, and in my university's full version of mathematica 5.2 on Linux. Johan === Subject: Re: Kernel Quits without error message. (Was: Better recursive method?) When trying to modify the example given by nandan, I arrive at a short > function that makes the Kernel quit without displaying any error or > warning message. With the definition pi[0, theta_] := 0; > pi[1, theta_] := 1; > pi[i_, theta_] := > pi[i, theta] = N[(2i - 1)/(i - 1) Cos[theta] pi[i - 1, theta] > - i/(i - 1) * pi[i - 2, theta]] and a high value for $RecursionLimit, I can evaluate pi[1000,1] in about > 0.06 seconds but the kernel quits when attempting pi[10000,1]. There is > neither warning nor error, and I see the same behaviour several times. I > have seen this both in my student version, and in my university's full > version of mathematica 5.2 on Linux. > Johan > Hi Johan, using version 5.2 on Linux: In[1]:= pi[i_, t_] = FullSimplify[p[i] /. First[ RSolve[{p[i] == ((2*i - 1)*Cos[t]*p[i - 1] - i*p[i - 2])/(i - 1), p[0] == 0, p[1] == 1}, p[i], i]], 0 < t < Pi] Out[1]= (-Csc[t])*LegendreP[i, 1, 2, Cos[t]] In[2]:= Timing[pi[10^3, 1.]] Out[2]= In[3]:= Timing[pi[10^4, 1.]] Out[3]= {17.513094*Second, -2.6056199971958973} but don't try N[pi[integer,exact number]] for large values of i: Timing[ N[pi[10^4,1]]] Out[6]={42.446654*Second, 2.414340966343630*10^315} Peter === Subject: pursuit curve (differential equations) hi i am doing pursuit curve in mathematica.. for instance, fox is chasing a rabbit - rabbit has a certain defined path (for example - a circle {cos(t),sin(t)}. fox always heads directly toward the rabbit. k - relative speed fox/rabbit p,q - rabbit's path (for instance a circle {cos(t),sin(t)} x,y - fox's path t - time :) soln = NDSolve[ { x'[t] == k.Sqrt[p'[t]^2 + q'[t]^2].(p - x[t]) /Sqrt[(p - x[t])^2 + (q - y[t])^2], y'[t] == k.Sqrt[p'[t]^2 + q'[t]^2].(y - q[t]) /Sqrt[(p - x[t])^2 + (q - y[t])^2], x[0] == poc0[[1]], y[0] == poc0[[2]] }, {x[t], y[t]}, {t, t0, t1}]; but this wont work, any suggestions? === Subject: Re: pursuit curve (differential equations) > hi i am doing pursuit curve in mathematica.. for instance, fox is chasing a > rabbit - rabbit has a certain defined path (for example - a circle > {cos(t),sin(t)}. fox always heads directly toward the rabbit. k - relative speed fox/rabbit > p,q - rabbit's path (for instance a circle {cos(t),sin(t)} > x,y - fox's path > t - time :) soln = NDSolve[ > { > x'[t] == k.Sqrt[p'[t]^2 + q'[t]^2].(p - x[t]) > /Sqrt[(p - x[t])^2 + (q - y[t])^2], > y'[t] == k.Sqrt[p'[t]^2 + q'[t]^2].(y - q[t]) ----------------------------------------------^ Missing variable: must be written y[t] > /Sqrt[(p - x[t])^2 + (q - y[t])^2], > x[0] == poc0[[1]], > y[0] == poc0[[2]] ------------------^^^^^^^^^ What are the numerical values for the 1 by 2 vector poc0? > }, > {x[t], y[t]}, {t, t0, t1}]; --------------------------^^--^^ What are the numerical values for t0 and t1? but this wont work, any suggestions? > Jean-Marc === Subject: Re: pursuit curve (differential equations) Hi Trijezni, you have syntax errors: . should be * and is not necessery. Functions must be written with arguments. See below. Daniel > hi i am doing pursuit curve in mathematica.. for instance, fox is chasing a > rabbit - rabbit has a certain defined path (for example - a circle > {cos(t),sin(t)}. fox always heads directly toward the rabbit. k - relative speed fox/rabbit > p,q - rabbit's path (for instance a circle {cos(t),sin(t)} > x,y - fox's path > t - time :) soln = NDSolve[ > { > x'[t] == k.Sqrt[p'[t]^2 + q'[t]^2].(p - x[t]) ^ ^ > /Sqrt[(p - x[t])^2 + (q - y[t])^2], ^ ^ > y'[t] == k.Sqrt[p'[t]^2 + q'[t]^2].(y - q[t]) ^ ^ > /Sqrt[(p - x[t])^2 + (q - y[t])^2], ^ ^ > x[0] == poc0[[1]], > y[0] == poc0[[2]] > }, > {x[t], y[t]}, {t, t0, t1}]; but this wont work, any suggestions? > === Subject: StoppingTest Constraints in NDSolve I'm using the NDSolve operation in Mathematica, and I need to add several constraints in the StoppingTest option. How should I do this ? More specifically, I want the iteration to stop if : (x[t] - 1)^2 + y[t]^2 + z[t]^2 < 0.5 and (x[t] + 2)^2 + y[t]^2 + z[t]^2 < 0.5 How to tell this in the StoppingTest option ? === Subject: Re: StoppingTest Constraints in NDSolve I'm using the NDSolve operation in Mathematica, and I need to add several constraints in the StoppingTest option. How should I do this ? More specifically, I want the iteration to stop if : (x[t] - 1)^2 + y[t]^2 + z[t]^2 < 0.5 and (x[t] + 2)^2 + y[t]^2 + z[t]^2 < 0.5 How to tell this in the StoppingTest option ? > Use RuleDelayed ( :> ) to specify the conditions and a logical and ( && ) to link both inequalities. For example, NDSolve[ ... , ... ,StoppingTest :> (x[t] - 1)^2 + y[t]^2 + z[t]^2 < 0.5 && (x[t] + 2)^2 + y[t]^2 + z[t]^2 < 0.5] Jean-Marc === Subject: Re: simple equation manipulation > Hi I have: > ( (a - 6k^2(c+b)) > / k^2) I want: > a/k^2 - 6(c+b) > Using mathematica, what command does this? Andrew > In[1]:= Apart[(a - 6*k^2*(b + c))/k^2] Out[1]= a/k^2 - 6*(b + c) Andrzej Kozlowski === Subject: Re: simple equation manipulation If you're willing to settle for -6*(b + c) + a/k^2 then just feed your fraction to Apart. > Hi I have: > ( (a - 6k^2(c+b)) > / k^2) I want: > a/k^2 - 6(c+b) > Using mathematica, what command does this? Andrew > -- 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: simple equation manipulation (a-6k^2(c+b))/k^2 // FullSimplify -6*(b + c) + a/k^2 Bob Hanlon > Hi I have: > ( (a - 6k^2(c+b)) > / k^2) I want: > a/k^2 - 6(c+b) > Using mathematica, what command does this? Andrew === Subject: Re: Profile (Wolfram Workbench) Here is the output of the Profile command for one of my inputs. http://test.chris.chiasson.name/Engineering_Optimization/profileTest.nb If you want to see the relevant source code, type docBookTableGeneral into the search box on this page to be taken to the relevant location in the source: A good approximation to the table in my test command would be... Map[If[NumberQ@#,ToString@#,#]&, Prepend[Array[Random[Real,{-1,10}]&,{79,12}], Flatten@Module[{v,b,h},{#,v,Table[b@i,{i,5}],Table[h@i,{i,5}]}]],{2}] > Actually, I am not sure what it is doing. Here is the second command I profiled: MapIndexed[If[NumberQ[#1],ToString[#1],#1]&,Prepend[evals[standard[equalSegme ntLength]][[2]],Flatten[{#,V,var[baseHeight]}]],{2}] It converts the numbers in a large table to strings. I realize > MapIndexed is unnecessary here. The evaluation table for this command only has one entry: True I was hoping for it to capture MapIndexed and the pure function. I lost the first command I profiled, but it produced zero entries in > the profile table. Maybe that happened because it was too fast? Anyway, I'm lost. :[ Is there a way to make the Profile command profile functions in the > System` context? I need to know what combination of functions is going > to work the fastest, but Profile leaves these functions out of its > summary. Also, the Profile command has no usage message... -- > http://chris.chiasson.name/ -- > http://chris.chiasson.name/ > -- http://chris.chiasson.name/ === Subject: Re: Profile (Wolfram Workbench) Actually, I am not sure what it is doing. Here is the second command I profiled: MapIndexed[If[NumberQ[#1],ToString[#1],#1]&,Prepend[evals[standard[equalSegm entLength]][[2]],Flatten[{#,V,var[baseHeight]}]],{2}] It converts the numbers in a large table to strings. I realize MapIndexed is unnecessary here. The evaluation table for this command only has one entry: True I was hoping for it to capture MapIndexed and the pure function. I lost the first command I profiled, but it produced zero entries in the profile table. Maybe that happened because it was too fast? Anyway, I'm lost. :[ > Is there a way to make the Profile command profile functions in the > System` context? I need to know what combination of functions is going > to work the fastest, but Profile leaves these functions out of its > summary. Also, the Profile command has no usage message... -- > http://chris.chiasson.name/ > -- http://chris.chiasson.name/ === Subject: Re: Profile (Wolfram Workbench) _?test that was being executed frequently. For now, I have removed the test and changed the pattern itself so that the pattern gives some of the same assurances that the test did - but they aren't fool proof. I should change functions that handle user input to be more strict than those that handle internally generated data. > Here is the output of the Profile command for one of my inputs. http://test.chris.chiasson.name/Engineering_Optimization/profileTest.nb If you want to see the relevant source code, type docBookTableGeneral > into the search box on this page to be taken to the relevant location > in the source: > A good approximation to the table in my test command would be... Map[If[NumberQ@#,ToString@#,#]&, > Prepend[Array[Random[Real,{-1,10}]&,{79,12}], > Flatten@Module[{v,b,h},{#,v,Table[b@i,{i,5}],Table[h@i,{i,5}]}]],{2}] Actually, I am not sure what it is doing. Here is the second command I profiled: MapIndexed[If[NumberQ[#1],ToString[#1],#1]&,Prepend[evals[standard[equalSegme ntLength]][[2]],Flatten[{#,V,var[baseHeight]}]],{2}] It converts the numbers in a large table to strings. I realize > MapIndexed is unnecessary here. The evaluation table for this command only has one entry: True I was hoping for it to capture MapIndexed and the pure function. I lost the first command I profiled, but it produced zero entries in > the profile table. Maybe that happened because it was too fast? Anyway, I'm lost. :[ Is there a way to make the Profile command profile functions in the > System` context? I need to know what combination of functions is going > to work the fastest, but Profile leaves these functions out of its > summary. Also, the Profile command has no usage message... -- > http://chris.chiasson.name/ -- > http://chris.chiasson.name/ -- > http://chris.chiasson.name/ > -- http://chris.chiasson.name/ === Subject: Profile (Wolfram Workbench) Is there a way to make the Profile command profile functions in the System` context? I need to know what combination of functions is going to work the fastest, but Profile leaves these functions out of its summary. Also, the Profile command has no usage message... -- http://chris.chiasson.name/ === Subject: Re: Newbie question - saving file in command-line You would be saving to a .m file because a .nb file isn't necessary in terminal mode. I believe the way to do this is by modifying $Pre and $Post, but I have never tried it. The idea is to have Mathematica write out your commands after parsing but before evaluation. > I am a new user of Mathematica, and tend to use the command-line version > more than the notebook interface. I would like to know how I can save my > work in .nb format when I'm in the command-line environment, that is, save > all my input and output so that when I open the .nb file in the notebook > interface, all my work will still be intact. > Rayne > -- http://chris.chiasson.name/ === Subject: Newbie question - saving file in command-line I am a new user of Mathematica, and tend to use the command-line version more than the notebook interface. I would like to know how I can save my work in .nb format when I'm in the command-line environment, that is, save all my input and output so that when I open the .nb file in the notebook interface, all my work will still be intact. Rayne === Subject: Re: Newbie question - saving file in command-line Rayne, There's a section Session Logging in Roman Maeder's book, Programming in Mathematica that tells you exactly how to do this. Section 9.4.3 even tells you how to save the log as a notebook. I occasionally use these methods for running long calculations in batch mode. But the notebook interface is so much better for anything interactive. John Jowett I am a new user of Mathematica, and tend to use the command-line version more than the notebook interface. I would like to know how I can save my work in .nb format when I'm in the command-line environment, that is, save all my input and output so that when I open the .nb file in the notebook interface, all my work will still be intact. Rayne === Subject: Re: Newbie question - saving file in command-line > I am a new user of Mathematica, and tend to use the command-line version > more than the notebook interface. I would like to know how I can save my > work in .nb format when I'm in the command-line environment, that is, save > all my input and output so that when I open the .nb file in the notebook > interface, all my work will still be intact. > Rayne Hi Rayne, the frontend exists to have the possibility to work with notebooks. You can try to DumpSave your session and read this into an empty notebook using the frontend. The input will be lost. I almost never use the naked math. Perhaps someone else has a better idea. Peter === Subject: Re: pursuit curve (differential equations) Hi Pijanac, Go to the link : http://mathworld.wolfram.com/PursuitCurve.html It also has a mathematica notebook that can solve your problem. Nabeel hi i am doing pursuit curve in mathematica.. for instance, fox is chasing > a > rabbit - rabbit has a certain defined path (for example - a circle > {cos(t),sin(t)}. fox always heads directly toward the rabbit. k - relative speed fox/rabbit > p,q - rabbit's path (for instance a circle {cos(t),sin(t)} > x,y - fox's path > t - time :) soln = NDSolve[ > { > x'[t] == k.Sqrt[p'[t]^2 + q'[t]^2].(p - x[t]) > /Sqrt[(p - x[t])^2 + (q - y[t])^2], > y'[t] == k.Sqrt[p'[t]^2 + q'[t]^2].(y - q[t]) > /Sqrt[(p - x[t])^2 + (q - y[t])^2], > x[0] == poc0[[1]], > y[0] == poc0[[2]] > }, > {x[t], y[t]}, {t, t0, t1}]; but this wont work, any suggestions? -- Nabeel Butt LUMS,Lahore === Subject: How it can be autoloaded an standard package using Mathematica link for EXCEL 3 How I can evaluate, using Math link for Excel 3, a function from a Mathematica package every time that I open the excel file?. For instance: In an Excel worksheet I have: 1., 2., 3., 4.in cells A1:A4 and 2 in cell A5. Then, using the fM icon I load the package DescriptiveStatistic and I write +EVAL(CentralMoment, A1:A4, A5) obtaining the second order moment for {1., 2., 3., 4.}. It works. However if I save and close the excel file when I open again this file the function +EVAL(CentralMoment, A1:A4, A5]) does not work. I need repead all the process, loading again DescriptiveStatistic. In version 2 the package it autoloaded when the Mathematica link was established. Any help! Guillermo === Subject: taking partial derivatives with respect to vector elements: need help with syntax I would like to take a partial derivative with respect to a variable which is indexed within a sum. Among other things I'm trying the following: Sum[x[[i]], {i, N}] which works when I specify x={1,2,3} and N=3, but I want to keep x and N unspecified. In which case it produces the message: Part:::pspec : Part specification i is neither an integer nor a list of integers. I am aiming for something similar to the following: D[Sum[x[[i]],{i,N}],x[2]] or even D[Sum[x[[i]],{i,N}],x[j]] I realize this is quite a rookie-question but I couldn't figure it out with the mathematica help + book. === Subject: Re: How install tools for mmade? can anybody give some link to it? > Murray, > If you could post to the group or otherwise write down most (or all) > of the problems you encounter (and solutions if possible) while you > start using MMADE and DocBook, it would be a valuable information > resource for me and the people that eventually use MMADE after you. It > would be especially helpful if you could write down your thinking > (stream of consciousness style), perhaps like: I wanted to do [item 1] with MMADE, so I downloaded [something] and > installed it, because I thought it would help. However, things didn't > work out because [issue]. or I decided to make a table with [stuff] in it, and I used [command], > but it didn't work. After posting to the group, I found out that the > reason is [reason]. Of course, you don't have to :-] >> I'd like some help with installing the the various other tools that >> help render the documents in order to get Chris Chiasson's mmade >> package to work under Windows XP. >> The instructions at >> on mmade, but my postings don't seem to appear.) >> In particular: >> 1. How/where does one install the DocBook stylesheets? >> 2. What particular XEP files do I want? >> -- >> 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 > -- > http://chris.chiasson.name/ > === Subject: Numerical Integrate I need to perform the following integration: Integrate[ Convolution[G(t), X(t)], {t, -inf, 0}], where G is Normal distribution, and X is Log-normal distribution. As I know, there is no analytical form for the convolution. I tried NIntegrate to perform numerical calculation, but Mathematica can't accept it. Does anyone know how to deal such problem? === Subject: Finding bounds of the domain of a Piecewise function Hi All, I have a routine that builds up a complicated Piecewise function, f[x]. All the pieces in the piecewise are restricted to some finite range (the ranges for each piece may be very different). I want to find the absolute extreme x values which will give me a non-zero f[x]. So have something along the lines of: f[x_]:=Piecewise[{ {f1[x], a <= x <= b}, {f2[x], c <= x <= d}, {f3[x], e <= x <= g} }] We can assume that a < b, c < d and e < g (all bounds are real and have a numeric value). We can also assume that the ranges are non-overlapping (it seems PiecewiseExpand takes care of that). However, we can *not* assume that the segments are sorted by the x range. Note also that the real problem will have many more segments than just 3. For the purposes of discussion, assume that Max[b,d,g] == b. I want to find a robust and reasonably fast way of extracting b. One idea is: Max[ Reap[ f[x][[1,All,2]]/.{r_?NumericQ :> Sow[r]} ][[2]] ] However, this seems like a bit of a hack (it is very much limited to the details of this particular problem). Is there a better way which doesn't require quite so many assumptions? === Subject: Re: Running Galois.m on Version 2.2.2 Hi Artur, After some trouble getting my Mac SE/30 started (hard drive is dying), I loaded the galois.m and tried the examples from the first 5 pages and the first one on page 6 of GalComp.nb. The Factor problem never finished after 15 hours. I had to shutdown the system and have not been able to start it again. I wanted to try the examples on pages 8 and 9 to see the plot, but can't. Hope this helps as far as it goes. >I would like to ask who is able do Mathematica ver 2.x Galois.m from >http://library.wolfram.com/infocenter/Articles/2872/ >working Galois.nb on Mathematica ver 5.x >ARTUR JASINSKI >POLAND === Subject: FourierTransform help I can't seem to plot the result of what I would think would be a simple transform. The following code at least attempts to run with no errors but it doesn't seem to stop. I plan to let it run all night. But surely one of you wizards knows a way to get this to output a result quickly. If so, I would appreciate your help. s[t_] := Cos[t] Exp[-t^2] Plot[Abs[Evaluate[FourierTransform[s[t], t, ìÅ]]], {ìÅ, -3,3}] === Subject: Re: Re: Newbie question - saving file in command-line As I'm aware this is the best Idea he can have for using the command-line interface. However, according to documentation and some experimentation I made everything is lost besides the definitions. He will need to re-generate the results in the front-end after loading the .mx file yehuda I am a new user of Mathematica, and tend to use the command-line version > more than the notebook interface. I would like to know how I can save my > work in .nb format when I'm in the command-line environment, that is, > save > all my input and output so that when I open the .nb file in the notebook > interface, all my work will still be intact. > Rayne Hi Rayne, the frontend exists to have the possibility to work with notebooks. > You can try to DumpSave your session and read this into an empty > notebook using the frontend. The input will be lost. I almost never use the naked math. Perhaps someone else has a better > idea. Peter === Subject: How to calculate gradient and laplace of a list I have a matrix of n*m read from a file. mathematica has built in function to do discrete fourier transform of the list. Can I calculate the gradient and the laplace of the matrix? I can use the listcontourplot to plot the matrix, Is there any way to plot the gradient plot of it? === Subject: Re: pursuit curve (differential equations) I became interested in your problem because your subject said, pursuit curve. Anyway, I don't really understand your code, so here is my attempt. Will someone please explain why the fox is so stupid? rep@params={rabbit->({Cos@#,Sin@#}&),k->2} vSubtract[args__?VectorQ]=Subtract[args] deqn=fox'[t]==k*Sqrt[rabbit'[t].rabbit'[t]]*vSubtract[rabbit@t,fox@t]&&fox[0 ]=={0,1/2}/.rep@params/.(Cos[blah_]^2+Sin[blah_]^2)->1 dsoln=NDSolve[deqn,fox,{t,0,3.5 [Pi]/2}] Needs[DifferentialEquations`InterpolatingFunctionAnatomy`] ParametricPlot@@{{fox@t,rabbit@t}/.dsoln[[1]]/.rep@params,Flatten@{t,Interpo latingFunctionDomain[fox/.dsoln[[1]]]},AspectRatio->Automatic,PlotStyle->{Red ,Black}} > hi i am doing pursuit curve in mathematica.. for instance, fox is chasing a > rabbit - rabbit has a certain defined path (for example - a circle > {cos(t),sin(t)}. fox always heads directly toward the rabbit. k - relative speed fox/rabbit > p,q - rabbit's path (for instance a circle {cos(t),sin(t)} > x,y - fox's path > t - time :) soln = NDSolve[ > { > x'[t] == k.Sqrt[p'[t]^2 + q'[t]^2].(p - x[t]) > /Sqrt[(p - x[t])^2 + (q - y[t])^2], > y'[t] == k.Sqrt[p'[t]^2 + q'[t]^2].(y - q[t]) > /Sqrt[(p - x[t])^2 + (q - y[t])^2], > x[0] == poc0[[1]], > y[0] == poc0[[2]] > }, > {x[t], y[t]}, {t, t0, t1}]; but this wont work, any suggestions? -- http://chris.chiasson.name/ === Subject: Re: pursuit curve (differential equations) What's poc0? Why use a dot? Don't you mean a simple multiplication (denoted by * or just juxtaposition with no symbol)? After all, p, q, x, and y presumably are already scalar-valued, not vector-valued. > hi i am doing pursuit curve in mathematica.. for instance, fox is chasing a > rabbit - rabbit has a certain defined path (for example - a circle > {cos(t),sin(t)}. fox always heads directly toward the rabbit. k - relative speed fox/rabbit > p,q - rabbit's path (for instance a circle {cos(t),sin(t)} > x,y - fox's path > t - time :) soln = NDSolve[ > { > x'[t] == k.Sqrt[p'[t]^2 + q'[t]^2].(p - x[t]) > /Sqrt[(p - x[t])^2 + (q - y[t])^2], > y'[t] == k.Sqrt[p'[t]^2 + q'[t]^2].(y - q[t]) > /Sqrt[(p - x[t])^2 + (q - y[t])^2], > x[0] == poc0[[1]], > y[0] == poc0[[2]] > }, > {x[t], y[t]}, {t, t0, t1}]; but this wont work, any suggestions? > -- 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: pursuit curve (differential equations) i think that you have some missing arguments in your equation. I tried to repair it (q->q[t], p->p[t] etc.)and here is the output: p[t_] := Sin[t]; q[t_] := Cos[t]; k = 10.; t0 = 0; t1 = 6Pi; poc0 = {1, 2}; soln = {x[t], y[t]} /. NDSolve[{x'[t] == k* Sqrt[p'[t]^2 + q'[ t]^2]*(p[t] - x[t])/ Sqrt[(p[t] - x[t])^2 + (q[t] - y[t])^2], y'[t] == k* Sqrt[p'[t]^2 + q'[t]^2]*(y[t] - q[t])/ Sqrt[(p[t] - x[t])^2 + (q[t] - y[ t])^2], x[t0] == poc0[[1]], y[t0] == poc0[[2]]}, {x[t], y[t]}, {t, t0, t1}][[1]] Josef Otta http://home.zcu.cz/~jotta 2007/1/22, Trijezni Pijanac : hi i am doing pursuit curve in mathematica.. for instance, fox is chasing > a > rabbit - rabbit has a certain defined path (for example - a circle > {cos(t),sin(t)}. fox always heads directly toward the rabbit. k - relative speed fox/rabbit > p,q - rabbit's path (for instance a circle {cos(t),sin(t)} > x,y - fox's path > t - time :) soln = NDSolve[ > { > x'[t] == k.Sqrt[p'[t]^2 + q'[t]^2].(p - x[t]) > /Sqrt[(p - x[t])^2 + (q - y[t])^2], > y'[t] == k.Sqrt[p'[t]^2 + q'[t]^2].(y - q[t]) > /Sqrt[(p - x[t])^2 + (q - y[t])^2], > x[0] == poc0[[1]], > y[0] == poc0[[2]] > }, > {x[t], y[t]}, {t, t0, t1}]; but this wont work, any suggestions? === Subject: Databaselink and MySQL I am trying to connect to a MySQL database using Mathematica's databaselink library. I can connect to the test databases provided with Mathematica (which are HSQL databases), and my MySQL databases work well on their own, but when I try to connect to the MySQL database from Mathematica, I get errors. My connection file looks like this: SQLConnection[JDBC[mysql, ToFileName[C:Program FilesMySQLMySQL Server 5.0data, dbsterntest]], Name -> MySQL test, Description -> test connection to MySQL database, Username -> root, Password -> $Prompt, RelativePath -> False, Version -> 1.] I have also tried with the OpenSQLConnection command directly, OpenSQLConnection[JDBC[mysql,C:Program FilesMySQLMySQL Server 5.0datadbsterntest],Username->root,Password->$Prompt] In both cases, I get the following error: JDBC::error: JDBC error: Cannot load connection class because of underlying exception: 'java.lang.NumberFormatException: For input string: Program FilesMySQLMySQL Server 5.0datadbsterntest'. Help? === Subject: Mathematica and ML (Functional Programming Language) I'm interested to know if anyone has knowledge of Matlink code for c function calls which would allow ML (Poly ML or SML:NJ) to be used as a developmental language in conjunction with MathLink Mathematica. If not I'll have to start form scratch; otherwise, I can use some examples. I didn't see any specific examples in the Documentation for ML, hence the reason for the question. Poly ML ,written by and used by David Matthews at CCL, has documentation for calling C functions in ML. THis is a specific Mathematica/ MathLink question. This has to do with ATP ( or Automated Theorem prover called Isabelle developed at Cambridge Computer Laboratories (CCL) by Larry son, built on HOL (High Order Logic). Clinton R. LeFort === Subject: Re: Notation related question I would like to build an environment for working on electrodynamics related problems using notations that mimics my writings on paper as closely as possible. Let say that there is a user defined type Vec so that E_Vec has internal representation {E_1,E_2,E_3}. Accordingly r_Vec would be represented internally as {r_1,r_2,r_3}. Than E[r] would be represented as {E_1[r_1,r_2,r_3],E_2[r_1,r_2,r_3],E_3[r_1,r_2,r_3]}. Assuming that the above construction is possible than a paper expression like div E(r) would be entered on the notebook as Div[E[r],Cartesian[r]]. I used to develop my code in Mathematica and generate Fortran code for production so that I would like to be able to: - formulate (exactly) a finite/infinite domain electrodynamic problem. - use DSolve or NDSolve (for simple test cases). - to generate Fortran formatted output (after proper discretization). > Could you maybe show us exactly how you intend to use these vectors? > That should make it easier to answer your questions, because your > current question does not make a lot of sense within the context of > how the front end and the kernel work. > I want to make a function that takes an argument V and returns a list >> build of V with subscripts 1,2.3: V -> {V_1, V_2, V_3}. >> I symbolize V and define the function: >> Symbolize[NotationBoxTag[(V__)]] >> Vec[V_]:={V_1, V_2, V_3}. >> It works as I expect for V but Vec[X] returns {V_1,V_2,V_3} instead of >> {X_1,X_2,X_3} as I expect. >> Anoter related (I think) question I have is how to define a _Vec type so >> that once I declare X_Vec the internal representation of X to be {X_1, >> X_2, X_3}? >> Ted === Subject: Re: Notation related question Could you maybe show us exactly how you intend to use these vectors? That should make it easier to answer your questions, because your current question does not make a lot of sense within the context of how the front end and the kernel work. > I want to make a function that takes an argument V and returns a list > build of V with subscripts 1,2.3: V -> {V_1, V_2, V_3}. I symbolize V and define the function: Symbolize[NotationBoxTag[(V__)]] > Vec[V_]:={V_1, V_2, V_3}. It works as I expect for V but Vec[X] returns {V_1,V_2,V_3} instead of > {X_1,X_2,X_3} as I expect. Anoter related (I think) question I have is how to define a _Vec type so > that once I declare X_Vec the internal representation of X to be {X_1, > X_2, X_3}? Ted -- http://chris.chiasson.name/ === Subject: Notation related question I want to make a function that takes an argument V and returns a list build of V with subscripts 1,2.3: V -> {V_1, V_2, V_3}. I symbolize V and define the function: Symbolize[NotationBoxTag[(V__)]] Vec[V_]:={V_1, V_2, V_3}. It works as I expect for V but Vec[X] returns {V_1,V_2,V_3} instead of {X_1,X_2,X_3} as I expect. Anoter related (I think) question I have is how to define a _Vec type so that once I declare X_Vec the internal representation of X to be {X_1, X_2, X_3}? Ted === Subject: Re: plot question Dimitris Consider the following graph of the function -ln(|x|). Plot[-Log[Abs[x]], {x, -2, 2}, PlotRange -> {Automatic, {-1, 3.5}}, >Axes -> False, Frame -> True, PlotPoints -> 100, FrameLabel -> {x, >y}] How is it possible to make the y-axis point downwards (I need this >because in half-space problems within the solid mechanics the >possitive vertical axis is pointed into the half-space)? I am not sure I understand what you mean by make the y-axis > point downwards. I am guessing you want the increasingly > positive tick values to appear toward the bottom of the page. If > I have this right perhaps you will find the following satisfactory Plot[-Log[Abs[x]], {x, -2, 2}, PlotRange -> {Automatic, {-1, > 3.5}}, Axes -> False, Frame -> True, PlotPoints -> 100, > FrameLabel -> {x, > y}, FrameTicks -> {Automatic, Transpose[{ > Range[0, 3], Range[3, 0, -1]}], {}, {}}]; > -- > To reply via email subtract one hundred and four === Subject: Re: Difficulties with Complex-Modulus Series Hi Carlos, In this version, Series does not expand Abs[] at all! The reason may be that Series uses D and D can not differentiate Abs. Remember, Abs is not a diferentiable function. Daniel > Say I have r = (2*I+x)/(2*I-x), in which x is real and nonnegative. Series[r,{x,0,4}] and Series[r,{x,Infinity,4}] work as expected. Introduce now R=Abs[r] and try the same: Series[R,{x,0,4}] and Series[R,{x,Infinity,4}] Results are now contaminated with Abs'[-1], Abs''[-1], etc, > I dont understand the presence of those derivatives. > Anybody can explain the reason? (I teach students that the > derivative of a constant is zero, but perhaps that has changed > with the new year) BTW it would be nice to say Series[R,{x,0,4}, x>=0] or Series[R,{x,0,4}, R>=0] etc if that would get rid of the garbage, but Mathematica 5 > does not allow Assumptions in Series. Note BTW that R=1 for > any x, so the R series are in fact trivial to any order. > === Subject: Re: Difficulties with Complex-Modulus Series > Say I have r = (2*I+x)/(2*I-x), in which x is real and nonnegative. Series[r,{x,0,4}] and Series[r,{x,Infinity,4}] work as expected. Introduce now R=Abs[r] and try the same: Series[R,{x,0,4}] and Series[R,{x,Infinity,4}] Results are now contaminated with Abs'[-1], Abs''[-1], etc, > I dont understand the presence of those derivatives. > Anybody can explain the reason? (I teach students that the > derivative of a constant is zero, but perhaps that has changed > with the new year) BTW it would be nice to say Series[R,{x,0,4}, x>=0] or Series[R,{x,0,4}, R>=0] etc if that would get rid of the garbage, but Mathematica 5 > does not allow Assumptions in Series. Note BTW that R=1 for > any x, so the R series are in fact trivial to any order. > Hi Carlos, What version of Mathematica and system platform were you using when you performed your tests? I ask because I have been unsuccessful in my attempts to get any derivatives of the function *Abs*. In[1]:= $Version r = (2*I + x)/(2*I - x); R = Abs[r]; Series[R, {x, 0, 4}] Series[R, {x, Infinity, 4}] Out[1]= 5.2 for Microsoft Windows (June 20, 2005) Out[4]= 2 I + x Abs[-------] 2 I - x Out[5]= 2 I + x Abs[-------] 2 I - x As we can see, both calls of the *Series* function only returned the callee function. Now, the built-in Mathematica function *Abs* is meant to work with numeric argument only: Abs[z] is left unevaluated if z is not a numeric quantity [1]. Since r is not a numeric expression, the Abs[r] is left untouched and especially there is no attempt to simplify or transform r. In[6]:= NumericQ[r] Out[6]= False The closest thing to your result I could get is by differentiating R w.r.t. x In[7]:= D[R, x] Out[7]= 1 2 I + x 2 I + x (------- + ----------) Abs'[-------] 2 I - x 2 2 I - x (2 I - x) Substituting a numeric value for x, we get In[8]:= % /. x -> 2 Out[8]= 1 -(-) Abs'[-I] 2 The above result should have been zero. If we nudge Mathematica to simplify the result, we get ride of the derivative of a constant (possibly evaluated to one) but still have some value with a change of sign. In[9]:= ComplexExpand[%] Out[9]= 1 - 2 Is this a bug or a feature, I don't know: at this point, I just gave up! Jean-Marc [1] http://documents.wolfram.com/mathematica/functions/Abs === Subject: Re: Difficulties with Complex-Modulus Series Hi Carlos, What version of Mathematica and system platform were you using when you > performed your tests? I ask because I have been unsuccessful in my attempts to get any > derivatives of the function *Abs*. Mathematica 5.0 on a dual processor Mac G5. Abs[] seems to be broken in that version so that function better be avoided. Hopefully it is fixed in newer versions. But in general the manipulation of complex entities has been very poorly implemented since the first version I used (2.2 on a Next machine). Perhaps it was never given priority. The main weakness is lack of interoperability. For the example I was able to get R=1 after some gyrations involving Re[], Im[], ComplexExpand[] and FullSimplify[]. But the actual complex numbers in my research (getting the spectral radius expansions of some feedback systems) are far more complicated, and for those nothing helps. === Subject: Re: Convolution Integral Could anyone please help me with the following? I'd like to find the convolution of 2 arbitrary > functions, f(t) and g(t) in the Laplace transform > sense,i.e., convolve[f[t],g[t]]=Integrate[f[u]*g[t-u],{u,0,t}] Thus, I'd like convolve[Sin[t],Exp[-t]] to return (Exp[-t]-Cos[t]+Sin[t])/2 . My several attempts with function definitions such as convolve[f_,g_]:=Integrate[f[u]*g[t-u],{u,0,t}] > convolve[f[t_],g[t_]]:=Integrate[f[u]*g[t-u],{u,0,t}] convolve[f_,g_][t_]:=Integrate[f[u]*g[t-u],{u,0,t}] all failed (because of the dummy u ? ) Sen. Hi Sen, The following thread, Function-type arguments in function definition, explains in detail what you are looking for (also with a convolution function.) Another approach is the following (although it does not work with pure functions.) We use replacement rules and an extra argument to indicate the name of the independent variable. In[1]:= ClearAll[convolve]; convolve[f_, g_][t_] := Module[{u}, Integrate[(f /. t -> u)*(g /. t -> t - u), {u, 0, t}]] In[3]:= convolve[Sin[t], Exp[-t]][t] Out[3]= 1 -t - (E - Cos[t] + Sin[t]) 2 In[4]:= convolve[Sin[x], Exp[-x]][x] Out[4]= 1 -x - (E - Cos[x] + Sin[x]) 2 Jean-Marc === Subject: Re: Convolution Integral Hello. Here is one place to look. http://mathworld.wolfram.com/Convolution.html Dimitris Could anyone please help me with the following? I'd like to find the convolution of 2 arbitrary > functions, f(t) and g(t) in the Laplace transform > sense,i.e., convolve[f[t],g[t]]=Integrate[f[u]*g[t-u],{u,0,t}] Thus, I'd like convolve[Sin[t],Exp[-t]] to return (Exp[-t]-Cos[t]+Sin[t])/2 . My several attempts with function definitions such as convolve[f_,g_]:=Integrate[f[u]*g[t-u],{u,0,t}] > convolve[f[t_],g[t_]]:=Integrate[f[u]*g[t-u],{u,0,t}] convolve[f_,g_][t_]:=Integrate[f[u]*g[t-u],{u,0,t}] all failed (because of the dummy u ? ) Sen. > ___ > Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com === Subject: Convolution Integral a lot about # . M.R.A. Sen ___ Now you can scan emails quickly with a reading pane. Get the new Yahoo! Mail. http://uk.docs.yahoo.com/nowyoucan.html === Subject: Decision tree algorithm Does anyone happen to have a Mathematica implementation of a decision tree algorithm (e.g., http://en.wikipedia.org/wiki/C4.5_algorithm) ? -Mark === Subject: Re: a old post again > See again my post here > I wonder why Mathematica 5.2 fails to evaluate symbolically the > following integral Integrate[(Log[a*x]/Sqrt[1 + x^2])*BesselJ[0, x], {x, 0, Infinity}] > BesselI[0, 1/2]*BesselK[0, 1/2]*Log[a] %/.a->0 > 0 Presumably you mean % /. a->1. In any case, the result of Integrate is wrong. The development version of Mathematica returns it unevaluated. > NIntegrate[(Log[x]/Sqrt[1 + x^2])*BesselJ[0, x], {x, 0, Infinity}, > Method -> Oscillatory] > -0.9979393746360525 whereas Mathematica 4.0 succeds? Dimitris Succeeds is a bit subjective. It returns an unevaluated Sum. A design decision was made to not allow such results. Actually I had thought this was decided long before version 4 so I'm surprised this persisted so long. There are now rare cases in which such sums may again be used as results for Integrate (piecewise integrands with infinitely many intervals of support). Daniel Lichtblau Wolfram Research === Subject: Re: a old post again Well, the old result was wrong :) In[1]:= $Version In[2]:= Integrate[(Log[a*x]/Sqrt[1 + x^2])*BesselJ[0, x], {x, 0, Infinity}] //InputForm Out[2]//InputForm= BesselI[0, 1/2]*BesselK[0, 1/2]*Log[a] In[3]:= N[% /. a->2] Out[3]= 0.681436 In[4]:= NIntegrate[(Log[a*x]/Sqrt[1 + x^2])*BesselJ[0, x] /. a->2, {x, 0, Infinity}, Method->Oscillatory] Out[4]= -0.316503 Bhuvanesh, Wolfram Research. === Subject: Re: a old post again I assume you mean that Integrate's result is wrong and NIntegrate's is right. Dimitris ì/.82 Bhuvanesh [NonBreakingSpace].8b.96.87¿.8c: > Well, the old result was wrong :) In[1]:= $Version > In[2]:= Integrate[(Log[a*x]/Sqrt[1 + x^2])*BesselJ[0, x], {x, 0, Infinity}] //InputForm Out[2]//InputForm= BesselI[0, 1/2]*BesselK[0, 1/2]*Log[a] In[3]:= N[% /. a->2] Out[3]= 0.681436 In[4]:= NIntegrate[(Log[a*x]/Sqrt[1 + x^2])*BesselJ[0, x] /. a->2, {x, 0, Infinity}, Method->Oscillatory] Out[4]= -0.316503 Bhuvanesh, > Wolfram Research. === Subject: Re: Dashing and PDF Hi Julia, the following works with AdobeReader 8: g = Show[Graphics[{Dashing[{.1, .1}], Line[{{0, 0}, {1, 1}}]}]]; Export[d:tmpt.pdf, g, PDF] Daniel > I'm having a bad time exporting PDFs from mathematica. The problem seems > to be down to having a plot using Dashing in its PlotStyle. It works > just fine within mathematica, and apparently can export a PDF file. > However Adobe Acrobat says Illegal operation inside a path when I try > open it, though Preview is happy to open it. I usually want to open the PDFs in acrobat to crop white margins as they > seem to always come out of mathematica with a bunch of space underneath. Is anyone else having problems opening exported PDFs in acrobat, > particularly with dashed lines? > Julia > === Subject: Re: Dashing and PDF one seems really pathological, but here is an example for something which does not work on mine: (OSX, Mathematica 5.2, Adobe Acrobat 7.0 Professional) g = ListPlot[Table[{ i, i }, {i, 1, 50}], PlotStyle -> Dashing[{0.01, 0.01}], PlotJoined -> True]; fa = Show[{g, g}]; Export[t.pdf, fa, PDF]; Necessary features to reproduce the error seem to be: -joined up ListPlot -two plotted together in Show -dashing -A MULTIPLE OF 50 POINTS in listplot table This is clearly weird and I would be curious to see if this works or not for anyone else. However it is easy enough for me to work around now in any case (60 points!). Julia > Hi Julia, > the following works with AdobeReader 8: g = Show[Graphics[{Dashing[{.1, .1}], Line[{{0, 0}, {1, 1}}]}]]; Export[d:tmpt.pdf, g, PDF] Daniel >> I'm having a bad time exporting PDFs from mathematica. The problem seems > to be down to having a plot using Dashing in its PlotStyle. It works > just fine within mathematica, and apparently can export a PDF file. > However Adobe Acrobat says Illegal operation inside a path when I try > open it, though Preview is happy to open it. >> I usually want to open the PDFs in acrobat to crop white margins as they > seem to always come out of mathematica with a bunch of space underneath. >> Is anyone else having problems opening exported PDFs in acrobat, > particularly with dashed lines? >> Julia > === Subject: Re: Nonautonomous ODEs Hi Virgil, You can use this approach for solving your problem: a = 36; b = 12; c = 145; t0 = 0; tmax = 20; jumps = Flatten[ Table[{{1, (i < x < i + 0.3)}, {0, (i + 0.3 <= x < i + 1)}}, {i, 0, tmax - 1}], 1]; F[x_] := Piecewise[jumps] eqn = a x''[t] + b x'[t] + c x[t] == F[t]; Plot[f[t], {t, t0, tmax}] soln = NDSolve[{eqn, x[0] == 0, x'[0] == 0}, x[t], {t, t0, tmax}]; Plot[Evaluate[x[t] /. soln], {t, t0, tmax}]; I hope, that it will solve your problem. Josef Otta http://home.zcu.cz/~jotta 2007/1/16, Virgil Stokes : I am having a problem with the numerical solution of non-autonomous > ODEs. For example, I have the following code for a simple linear 2nd > order ODE with a forcing function, F[t_] Clear[x,t] > a = 36; > b = 12; > c = 145; > t0=0; tmax = 20; > eqn := a x''[t] + b x'[t] + c x[t] == F[t] > F[t_] := 100 Exp[-t/6]Cos[2 t]; The following code gives its analytical solution and a plot of the > solution for zero initial conditions, soln = DSolve[{eqn,x[0]==0,x'[0]==0},x[t],t]//Simplify > truesoln = x[t]/.soln > Plot[truesoln,{t,t0,tmax}]; The numerical solution and its plot can be obtained with, soln = NDSolve[{eqn,x[0]==0,x'[0]==0},x[t],{t,t0,tmax}]; > Plot[Evaluate[x[t]/.soln],{t,t0,tmax}]; My problem, is that suppose the driving function is a sequence of unit > amplitude rectangular pulses, each with width of 0.3 and having a period > 1.0, then how can F[t_] be defined so that NDSolve can be used to obtain > a numerical solution? --V. Stokes