mm-929 === Subject: Solve[] and Eliminate[] choke on simple systems of equations I am trying to convert some of my old stuff from another system to Mathematica. Below is an example of a Markov model that takes the other system a couple of seconds to solve, but Mathematica chews on forever (I gave up after about 30 minutes). Since I'm a Mathematica newbie, perhaps there is some limitation I am not aware of? eqns = {3*L*P333 == U*(P323 + P322 + P223 + P221 + P120), (K + 2*L + U)*P323 == 3*L*P333, (K + 2*U + L)*P313 == 2*L*P323, (2*L + U)*P322 == 2*U*P312, (2*U + L)*P312 == 2*L*P322 + 3*U*P302, 3*U*P302 == L*P312 + L*P313, (2*L + U)*P223 == U*(2*P213 + P212) + 2*U*P313 + U*(2*P113 + P111) + K*P323, (K + 2*U + L)*P213 == 2*L*P223, (2*U + L)*P212 == L*P221 + 2*U*P202, 3*U*P202 == L*(P213 + P212 + P211), (2*L + U)*P221 == U*(P212 + 2*P211), (2*U + L)*P211 == L*P221 + U*P202 (L + 2*U)*P113 == K*P313 + K*P213 + U*P102, 3*U*P102 == L*P113 + L*P111, (2*U + L)*P111 == 2*U*P102 + 2*L*P120, (2*L + U)*P120 == U*P111, P333 + P323 + P313 + P322 + P312 + P302 + P223 + P213 + P212 + P202 + P221 + P211 + P113 + P102 + P111 + P120 == 1} vars = {P333, P323, P313, P322, P312, P302, P223, P213, P212, P202, P221, P211, P113, P102, P111, P120} A = Solve[eqns, vars] === Subject: Re: Solve[] and Eliminate[] choke on simple systems of equations you have 17 equations and 16 variables! I think there is something fishy with the tripple equation: (2*U + L)*P211 == L*P221 + U*P202 (L + 2*U)*P113 == K*P313 + K*P213 + U*P102 have fun Daniel === Subject: Re: Integrate (a curious result) I believe that the real reason is very close to what you have guessed on your post! More or less it must be something on the same vein. Otherwise it could be an internal problem of Integration agorithm for Mathematica 5.2 for Windows (the integral is platform dependent). Anyway... Dimitris =CF/=C7 Michael Weyrauch =DD=E3=F1=E1=F8=E5: ite integration. So, please, keep on asking these questions... see what is going on, knows the source lgorithms for discontinuities along hich may go wrong an idea how I should way as you do in your post. if the various limits exist or not. ess that it is this what happens in out the limits at this singularity and therefore onsistent with your observation culates the limits at the endpoints of the tegral is Infinity. it actually works... === Subject: Re: Efficient BesselJ and LegendreP Evaluation Hi Antonio. Your post apperared in quite unreadable format (take a look at the functions arguments). Anyway from our private communication I was able to see your integrals you are interested in. I will what I can do. Dimitris =CF/=C7 Antonio =DD=E3=F1=E1=F8=E5: Try ^4); ); E=B1Lim = =CE=B1Ma= er))^2]; CE=B1] + CE=B1] + Exp[-(f*(S= E=B1]]*(Bess= =B1])) - + B1]]*LegendreP= Legendre[n, m, =CF=81o*Si= === Subject: Re: Efficient BesselJ and LegendreP Evaluation Sorry for the greek letters in the code below I have replaced them with their names. Clear[Global`*]; Off[General::spell]; Off[General::spell1]; lambda = 0.8; w = 2500; NA = 1.25; f = 1700; d = 50.; nGlass = 1.4883 + 1.9023/(10^2*lambda^2) - 4.25016/(10^3*lambda^4); nWater = 1.3253 + 2.7553/(10^3*lambda^2) + 3.779/(10^5*lambda^4); nAir = 1.0001; alphaMax = ArcSin[NA/nWater]; ko = (2*Pi*nAir)/lambda; Nmax = 20; GridNM = Table[{n, m}, {n, 1, Nmax}, {m, 0, n}]; alphaCrit = ArcSin[nWater/nGlass]; If[alphaCrit < alphaMax, alphaLim = alphaCrit, alphaLim = alphaMax]; cosA2[(alpha_)?NumericQ] := Sqrt[1 - (nGlass*(Sin[alpha]/nWater))^2]; ts[(alpha_)?NumericQ] := 2*nGlass*(Cos[alpha]/(nGlass*Cos[alpha] + nWater*cosA2[alpha])); tp[(alpha_)?NumericQ] := 2*nGlass*(Cos[alpha]/(nWater*Cos[alpha] + nGlass*cosA2[alpha])); DBessel[m_, x_] := (1/2)*(BesselJ[-1 + m, x] - BesselJ[1 + m, x]); DLegendre[n_, m_, x_] := ((-1 - n)*x*LegendreP[n, m, x] + (1 - m + n)*LegendreP[1 + n, m, x])/(-1 + x^2); ITM[(n_Integer)?Positive, (m_Integer)?NonNegative, zo_Real, rhoo_Real] := Block[{func}, func[(alpha_)?NumericQ] := Sqrt[Cos[alpha]]*Exp[-(f*(Sin[alpha]/w))^2]*Exp[(-I)*ko*nWater*zo*cosA2[alph a]]* Exp[(-I)*ko*d*(nGlass*Cos[alpha] - nWater*cosA2[alpha])]*(m^2*ts[alpha]*LegendreP[n, m, cosA2[alpha]]*(BesselJ[m, ko*nGlass*rhoo*Sin[alpha]]/(ko*nGlass*rhoo*Sin[alpha])) - tp[alpha]*(nGlass/nWater)^2*Sin[alpha]^2*DBessel[m, ko*nGlass*rhoo*Sin[alpha]]*DLegendre[n, m, cosA2[alpha]] + I*m*(ts[alpha]*DBessel[m, ko*nGlass*rhoo*Sin[alpha]]*LegendreP[n, m, cosA2[alpha]] - tp[alpha]*(nGlass/nWater)^2*Sin[alpha]^2*DLegendre[n, m, cosA2[alpha]]* (BesselJ[m, ko*nGlass*rhoo*Sin[alpha]]/(ko*nGlass*rhoo*Sin[alpha])))); 1000]]; zo = Random[Real, {-10., 10.}]; rhoo = Random[Real, {0., 10.}]; Timing[MI1 = Apply[ITM[#1, #2, zo, rhoo] & , GridNM, {2}];] === Subject: Timing in Mathematica I am using Timing[.......] to calculate the time taken by an expression in Mathematica. But it is not showing values below 0.01 seconds. For values below 0.01s it just shows 0. Second Is it possible to get the value of time lower than 0.01s by somehow lowering the least count. I am using Mathematica 5.2 on Windows. I was getting lower values of time on Mathematica(5.2) on a Linux computer. Amit === Subject: Re: Timing in Mathematica It is very easy. Let for example foo = {x^n, Cos[x], Log[x]/x, Log[Sin[x]^2]*Tan[x], BesselJ[n, x], (2*x)/((x + 1)*(x^3 + 3*x^2 + 2*x + 1))} {x^n, Cos[x], Log[x]/x, Log[Sin[x]^2]*Tan[x], BesselJ[n, x], (2*x)/((1 + x)*(1 + 2*x + 3*x^2 + x^3))} Then InputForm[(Timing[Integrate[#1, x]] & ) /@ foo] {{0.031*Second, x^(1 + n)/(1 + n)}, {0.015999999999999986*Second, Sin[x]}, {0.*Second, Log[x]^2/2}, {0.9530000000000001*Second, Log[Sec[x/2]^2]^2 + 2*Log[Sec[x/ 2]^2]*Log[(Cos[x]*Sec[x/2]^2)/2] + Log[Sec[x/2]^2]*Log[Sin[x]^2] - 2*Log[Sec[x/2]^2]*Log[-1 + Tan[x/ 2]^2] - Log[Sin[x]^2]*Log[-1 + Tan[x/2]^2] + Log[Tan[x/2]^2]*Log[-1 + Tan[x/2]^2] + 2*PolyLog[2, Sec[x/2]^2/2] + PolyLog[2, Cos[x]*Sec[x/2]^2] + PolyLog[2, -Tan[x/2]^2]}, {0.030999999999999917*Second, 2^(-1 - n)*x^(1 + n)*Gamma[(1 + n)/2]* HypergeometricPFQRegularized[{(1 + n)/2}, {1 + n, (3 + n)/2}, - (x^2/4)]}, {0.016000000000000014*Second, 2*(-Log[1 + x] + RootSum[1 + 2*#1 + 3*#1^2 + #1^3 & , (Log[x - #1] + 2*Log[x - #1]*#1 + Log[x - #1]*#1^2)/(2 + 6*#1 + 3*#1^2) & ])}} Dimitris =CF/=C7 amitsoni.1984@gmail.com =DD=E3=F1=E1=F8=E5: === Subject: Re: Timing in Mathematica Hi Amit, if it is important to get these timings (because the functions are called in loops), I would do it with and divide the result by 10^4. === Subject: Re: Timing in Mathematica amitsoni.1984@gmail.com =EDrta: After doing some experimentation, I found that on my system AbsoluteTiming returns integer multiples of 0.015625 seconds. Timing returns the same values, but rounded to $TimeValue of 0.001. (Mathematica 5.2 on WinXP SP2) But you still shouldn't assume that timings are precise to 0.015625. For some reason, when I record several timing values with Table, the first one is always larger then the rest (significantly larger for short times). Here are two examples with very short timings: Table[First@ AbsoluteTiming[Do[NSum[i,{i,1,1000}],{1000}]]/Second,{100}]/ 0=2E015625 {36.,25.,26.,27.,29.,29.,28.,28.,27.,27.,26.,26.,26.,26.,25.,26.,25.,26.,26= ., 25.,26.,25.,26.,25.,26.,28.,25.,27.,26.,27.,26.,25.,27.,26.,26.,25.,26.,27.= , 26.,26.,25.,26.,27.,25.,26.,25.,25.,28.,26.,26.,28.,25.,26.,25.,27.,26.,26.= , 26.,26.,26.,25.,25.,26.,26.,29.,25.,26.,25.,25.,26.,25.,26.,25.,25.,26.,27.= , 25.,26.,25.,26.,25.,25.,26.,25.,25.,26.,25.,25.,26.,25.,25.,26.,25.,26.,25.= , 25.,25.,26.,25.,26.} Table[First@ AbsoluteTiming[Do[NSum[i,{i,1,1000}],{100}]]/Second,{100}]/ 0=2E015625 {6.,6.,2.,3.,2.,3.,2.,3.,2.,3.,2.,3.,2.,3.,2.,3.,2.,3.,2.,3.,2.,3.,2.,3.,2.= ,3. , 3=2E,2.,3.,2.,3.,2.,3.,2.,3.,2.,3.,2.,3.,2.,3.,2.,3.,2.,3.,2.,3.,2.,3.,3.,2= .,3. , 2=2E,3.,2.,3.,2.,3.,2.,3.,2.,3.,3.,2.,3.,2.,3.,2.,3.,3.,2.,3.,2.,3.,2.,3.,2= .,3. ,3.,2.,3.,2.,3.,2.,3.,2.,3.,2.,3.,3.,2.,3.,2.,3.,3.,2.,3.,2.,3.,2.} Other calculations inside Do[] or using Timing instead of AbsoluteTiming give similar results. I hope that this will persuade you not try to measure very short execution times. === Subject: Visual Basic I'm a french student and I use mathematica, I just want to know if it is po= ssible to run Mathematica from a Visual Basic program and to return the mat= hematica output in my window application. _________________________________________________________________ Essayez Live.com et cr=E9ez l'Internet qui vous ressemble : infos, sports, = m=E9t=E9o et bien plus encore ! http://www.live.com/getstarted === Subject: Re: Depurating tool I think you need Wolfram Workbench, a great new tool. Unfortunately, I guess, it is only available right now to Premier Service customers. But that you need to ask customer support of WRI. Michael Weyrauch === Subject: Re: verification ... Hi Dimitris, try this one: Reduce[And @@ Equal @@@ Subsets[foo, {2}] // ComplexExpand] Peter === Subject: Re: verification OK, so you easily showed that foo[[2]] and foo[[3]] are the same. Here's the easiest way I know to show that foo[[1]] and foo[[3]] are the same: In[4]:= FullSimplify[TrigToExp[foo[[1]]]] == FullSimplify[foo[[3]]] Out[4]= True What really disturbs me is that I can also show that foo[[1]] and foo[[3]] are NOT the same: In[6]:= FullSimplify[TrigToExp[foo[[1]]] == foo[[3]]] messages regarding Internal precision limit snipped Out[6]= False It seems that Mathematica is asserting that two _equal_ expressions are _not equal_. What am I missing?! (Of course, if Mathematica had merely left the logical expression unevaluated, I wouldn't have been disturbed...) BTW, I haven't found a direct way to use Mathematica to show that foo[[1]] and foo[[2]] are the same. David W. Cantrell === Subject: Re: verification In fact it is quite easy to prove using Mathematica that all the elements of foo must be equal although it needs a little human intervention. foo = {ArcTan[8/(1 - Sqrt[-15 - 4*I])] + ArcTan[8/(1 + Sqrt[-15 - 4*I])] + ArcTan[8/(1 - Sqrt[-15 + 4*I])] + ArcTan[8/(1 + Sqrt[-15 + 4*I])], ArcTan[3] + ArcTan[5] + ArcTan[41/3] + ArcTan[21], 2*Pi - ArcTan[1/4] - ArcTan[5/12]}; FullSimplify[Tan[foo[[2]]]-Tan[foo[[3]]]] 0 Since both foo[[2]] and foo[[3]] are real, in order to have equal values of Tan they must differ by a multiple of Pi but: Abs[foo[[2]]-foo[[3]]]