MaplePrimes - Questions and Posts tagged with efficient
http://www.mapleprimes.com/tags/efficient
en-us2014 Maplesoft, A Division of Waterloo Maple Inc.Maplesoft Document SystemThu, 17 Apr 2014 15:52:25 GMTThu, 17 Apr 2014 15:52:25 GMTThe most recent questions and posts on MaplePrimes tagged with efficienthttp://www.mapleprimes.com/images/mapleprimeswhite.jpgMaplePrimes - Questions and Posts tagged with efficient
http://www.mapleprimes.com/tags/efficient
Matrix and parallel computing / multicore
http://www.mapleprimes.com/questions/201381-Matrix-And-Parallel-Computing--Multicore?ref=Feed:MaplePrimes:Tagged With efficient
<p>Hi,</p>
<p>Is there any difference between</p>
<p>Matrix(4,5,(K,C)->K+C);</p>
<p>and</p>
<p>Array(1..4,1..5,(K,C)->K+C);</p>
<p> </p>
<p>Say if I have a very 'complicated' procedure myfunc(K,C) that takes two options, but it runs all dependently.</p>
<p>Matrix(4,5,(K,C)->myfunc(K,C));</p>
<p>and</p>
<p>Array(1..4,1..5,(K,C)->myfunc(K,C));</p>
<p>Which one is more efficient? The final ouput of each run from myfunc is just a integer value.</p>
<p> </p>
<p>The reason I am asking it that i think both runs on a 'single' thread (core) as CPU usage is always very low, around 15-20%.</p>
<p>If I look at the task manager, some cores (threads) arent doing anything.</p>
<p>Is there anyway to speed things up?</p>
<p> </p>
<p>Thanks,</p><p>Hi,</p>
<p>Is there any difference between</p>
<p>Matrix(4,5,(K,C)->K+C);</p>
<p>and</p>
<p>Array(1..4,1..5,(K,C)->K+C);</p>
<p> </p>
<p>Say if I have a very 'complicated' procedure myfunc(K,C) that takes two options, but it runs all dependently.</p>
<p>Matrix(4,5,(K,C)->myfunc(K,C));</p>
<p>and</p>
<p>Array(1..4,1..5,(K,C)->myfunc(K,C));</p>
<p>Which one is more efficient? The final ouput of each run from myfunc is just a integer value.</p>
<p> </p>
<p>The reason I am asking it that i think both runs on a 'single' thread (core) as CPU usage is always very low, around 15-20%.</p>
<p>If I look at the task manager, some cores (threads) arent doing anything.</p>
<p>Is there anyway to speed things up?</p>
<p> </p>
<p>Thanks,</p>201381Sat, 12 Apr 2014 23:12:06 Zcasperyccasperycproblem with system of ode's or maple ?
http://www.mapleprimes.com/questions/201177-Problem-With-System-Of-Odes-Or-Maple-?ref=Feed:MaplePrimes:Tagged With efficient
<p>hi all.<br>i have a system of ODE's including 9 set of coupled OED's . </p>
<p>i have converted second deravaties to dd2 , in other words : diff(a[i](t),t,t)=dd2[i](t) . i =1..9 :</p>
<p>and i have set these 9 equations in form of vibrational equations such : (M.V22)[i]+(K(t).V(t))[i]+P(t)[i] = eq[i] , where M is coefficient Matrix of second derivatives , V22 is Vector of second derivaties , for example V22[1] = diff(a[1](t),t,t) , and P(t) is the numeric part of equations ( they are pure number and do not contain any symbolic function ) and K(t).V(t) is the remaining part of equations such that : (K(t).V(t))[i] = eq[i] - (M.V22)[i] - P(t)[i] , and V(t) are vector of a[i](t)'s which V(t)[1] = a[1](t) ,<br><br>i have used step by step time integration method (of an ebook which i have attachted that part of ebook here), when i set time step of solving process to h=0.01 , i can solve this system up to time one second or more, but when i choose h=0.001 or smaller, the answer diverges after 350 steps . i do not know whether the problem is in my ODS system, or maple can not handle this <a href='http://www.maplesoft.com/support/help/search.aspx?term=the' target='_new'>?the</a> answer about the time t=0.3 are the same in both steps, but after that, the one with stpe time h=0.001 diverges. my friend has solved this in mathematica without any problem, could any body help me ?! it is urgent for me to solve this problem,thnx everybody.<br><br><br><a href="/view.aspx?sf=201177_question/ebook.pdf">ebook.pdf</a> <a href="/view.aspx?sf=201177_question/step_=_0.001.mw">step_=_0.001.mw</a> <a href="/view.aspx?sf=201177_question/step_=_0.01.mw">step_=_0.01.mw</a> </p><p>hi all.<br>i have a system of ODE's including 9 set of coupled OED's . </p>
<p>i have converted second deravaties to dd2 , in other words : diff(a[i](t),t,t)=dd2[i](t) . i =1..9 :</p>
<p>and i have set these 9 equations in form of vibrational equations such : (M.V22)[i]+(K(t).V(t))[i]+P(t)[i] = eq[i] , where M is coefficient Matrix of second derivatives , V22 is Vector of second derivaties , for example V22[1] = diff(a[1](t),t,t) , and P(t) is the numeric part of equations ( they are pure number and do not contain any symbolic function ) and K(t).V(t) is the remaining part of equations such that : (K(t).V(t))[i] = eq[i] - (M.V22)[i] - P(t)[i] , and V(t) are vector of a[i](t)'s which V(t)[1] = a[1](t) ,<br><br>i have used step by step time integration method (of an ebook which i have attachted that part of ebook here), when i set time step of solving process to h=0.01 , i can solve this system up to time one second or more, but when i choose h=0.001 or smaller, the answer diverges after 350 steps . i do not know whether the problem is in my ODS system, or maple can not handle this ?the answer about the time t=0.3 are the same in both steps, but after that, the one with stpe time h=0.001 diverges. my friend has solved this in mathematica without any problem, could any body help me ?! it is urgent for me to solve this problem,thnx everybody.<br><br><br><a href="/view.aspx?sf=201177_question/ebook.pdf">ebook.pdf</a> <a href="/view.aspx?sf=201177_question/step_=_0.001.mw">step_=_0.001.mw</a> <a href="/view.aspx?sf=201177_question/step_=_0.01.mw">step_=_0.01.mw</a> </p>201177Wed, 19 Mar 2014 18:09:24 Zmehdi jafarimehdi jafariMore efficient way? (quicker, less memory used, good practise of programming?)
http://www.mapleprimes.com/questions/146583-More-Efficient-Way-quicker-Less-Memory?ref=Feed:MaplePrimes:Tagged With efficient
<p>Hi all,</p>
<p>##################################################################</p>
<p>restart:<br><br>K:=50;C:=20;<br><br>st:=time():<br><br> for j from 2 to K do<br> for c to C do<br> solve({log(cat(p,j,'C',c)/(1-cat(p,j,'C',c)))=mu+cat(tau,j)+cat(eta,c)+cat(mix,j,c)},cat(p,j,'C',c));<br> assign(%);<br> ...<p>Hi all,</p>
<p>##################################################################</p>
<p>restart:<br><br>K:=50;C:=20;<br><br>st:=time():<br><br> for j from 2 to K do<br> for c to C do<br> solve({log(cat(p,j,'C',c)/(1-cat(p,j,'C',c)))=mu+cat(tau,j)+cat(eta,c)+cat(mix,j,c)},cat(p,j,'C',c));<br> assign(%);<br> end do;<br> end do;<br> <br>time()-st;<br><br>ppar:=[cat(p,2..K,'C',19)]:<br># ppar:<br># cat(p,'C',1..20);<br># seq([cat(p,2..K,'C',m)],m=1..20);<br><br>cat(p,'C',1..20):=seq([cat(p,2..K,'C',m)],m=1..20):<br>pC1;pC2;pC12;pC20;<br>##################################################################</p>
<p> </p>
<p>The time it took to run (about 9 or 10 sec) on my machine is more or less OK. But it seems that about 200MB is used.</p>
<p>I wonder is there a way to 'improve' this coding? Quicker and less memory used?</p>
<p> </p>
<p>Basically, the sequence of pC1,...,pC20 in the toy example is what i wanted.</p>
<p> </p>
<p>Also, the CPU does not seem to be 'fully' used. I have a quard core processor, I wonder if Maple has some sort of parrallel computing?</p>146583Thu, 02 May 2013 06:56:42 Zcasperyccasperycoptimization: disappointments again
http://www.mapleprimes.com/questions/127880-Optimization-Disappointments-Again?ref=Feed:MaplePrimes:Tagged With efficient
<p>As usual happens in symbolic calculations - small change of input parameters leads to drammatical change in consuptions. I had talk about many other partial issues in this forum. Many other issues i just tried myself without any success (for example try convert(exp(x)+x, FormalPowerSeries)) and now i must take decision: wheather or not to continue work with maple at all. It's totally clear for me that others (like Wolfram mathematica) not much better. Only one other...<p>As usual happens in symbolic calculations - small change of input parameters leads to drammatical change in consuptions. I had talk about many other partial issues in this forum. Many other issues i just tried myself without any success (for example try convert(exp(x)+x, FormalPowerSeries)) and now i must take decision: wheather or not to continue work with maple at all. It's totally clear for me that others (like Wolfram mathematica) not much better. Only one other case to solve my problem - implement series coefficients calculation by myself too.And then Jean-Baptiste Emanuel Zorg will 1001th time right again! "Want smth done? Do it yourself!"</p>
<p>For this moment i have code and all i want that functions will calculate fast enought irrespectivetly of input values (that consist over wide set of distributions and numerical values for them). Was partially succeded with k=1 before and now totally fail with k=3/2. Goddem what about other changes? Only series in general case should be solution. But how?</p>
<p>All i need for now - is implementation of 4 procedures:</p>
<p>IntermediateCalc</p>
<p>GetLimitsArray</p>
<p>SmallFuncSimpl</p>
<p>BigFuncSimpl</p>
<p>to get both reasonable result under CodeTools:-Usage namely for memory <200kb and for time less than 50ms. I'm pretty sure that this task completly solvable manually in all examples i should consider, but i don't know about universality.</p>
<p>Attach: <a href="/view.aspx?sf=127880/425349/main.mw">main.mw</a>.</p>
<p>All i want to know today: wheather it's possible to calculate so? YES or NO?</p>127880Sat, 19 Nov 2011 22:31:22 Zicegoodicegoodsimplification of many exponential terms
http://www.mapleprimes.com/questions/127545-Simplification-Of-Many-Exponential-Terms?ref=Feed:MaplePrimes:Tagged With efficient
<p>I have a solution containing many exponentail terms, some of which are in the denominators of rational terms. I would like to be able to have the solution given to me in a manner where there are no exponentials in denominators but only in the numerators. The simplify command in maple does it, however for the shear number of terms (just shy of 400,000 terms and maple saying it's million plus) i am looking at, that particular command is just taking too long (15 hours!). Is there...<p>I have a solution containing many exponentail terms, some of which are in the denominators of rational terms. I would like to be able to have the solution given to me in a manner where there are no exponentials in denominators but only in the numerators. The simplify command in maple does it, however for the shear number of terms (just shy of 400,000 terms and maple saying it's million plus) i am looking at, that particular command is just taking too long (15 hours!). Is there an efficient and easy way to do this?</p>127545Wed, 09 Nov 2011 05:58:13 ZmathgeekmathgeekBoolean evaluation
http://www.mapleprimes.com/questions/126283-Boolean-Evaluation?ref=Feed:MaplePrimes:Tagged With efficient
<p>In Maple boolean evaluation returns the values 'true' or 'false'.</p>
<p>Is there any canonical way of getting evalb to produce values in {0,1}? This is of some use when testing conjectures on hudge lists of items...</p>
<p>Of course: you can always define a script like</p>
<p>###########################<br>evalbb:=proc(PP)<br>if evalb(PP)='true' then eps:=1:<br>else eps:=0: <br>fi:<br>eps;<br>end:<br>###########################</p>
<p>but I think there should be...<p>In Maple boolean evaluation returns the values 'true' or 'false'.</p>
<p>Is there any canonical way of getting evalb to produce values in {0,1}? This is of some use when testing conjectures on hudge lists of items...</p>
<p>Of course: you can always define a script like</p>
<p>###########################<br>evalbb:=proc(PP)<br>if evalb(PP)='true' then eps:=1:<br>else eps:=0: <br>fi:<br>eps;<br>end:<br>###########################</p>
<p>but I think there should be something more direct: the machine certinly uses {0,1} and not {true,false}, so running the above script you are just translating forth and back - this means wasting time (or, at least, it does not seem to be very efficient).</p>126283Wed, 05 Oct 2011 19:14:44 ZCarlo CarminatiCarlo CarminatiMinimal polynomials in GF
http://www.mapleprimes.com/posts/121576-Minimal-Polynomials-In-GF?ref=Feed:MaplePrimes:Tagged With efficient
<p>Answering to that question, I posted several procedures finding minimal polynomials for the elements of finite fields. The best one was the following,</p>
<pre>alias(a=RootOf(T^100+T^97+T^96+T^93+T^91+T^89+T^87+T^86+T^82+T^81+T^71+T^70+T^67+T^61+
T^60+T^57+T^54+T^53+T^52+T^49+T^48+T^45+T^44+T^42+T^39+T^36+T^33+T^32+T^31+T^29+T^28+T^27+
T^26+T^24+T^23+T^22+T^18+T^17+T^16+T^14+T^13+T^12+T^10+T^8+T^7+T^6+T^3+T+1)):
F:=GF(2,100,op(a)):
z:=F:-input(2):
MinPolyGF:=proc(x,y:=_X)
local A, i;
A:=Matrix(100,...</pre><p>Answering to that question, I posted several procedures finding minimal polynomials for the elements of finite fields. The best one was the following,</p>
<pre>alias(a=RootOf(T^100+T^97+T^96+T^93+T^91+T^89+T^87+T^86+T^82+T^81+T^71+T^70+T^67+T^61+
T^60+T^57+T^54+T^53+T^52+T^49+T^48+T^45+T^44+T^42+T^39+T^36+T^33+T^32+T^31+T^29+T^28+T^27+
T^26+T^24+T^23+T^22+T^18+T^17+T^16+T^14+T^13+T^12+T^10+T^8+T^7+T^6+T^3+T+1)):
F:=GF(2,100,op(a)):
z:=F:-input(2):
MinPolyGF:=proc(x,y:=_X)
local A, i;
A:=Matrix(100,[seq([op(F:-`*`(x,F:-`^`(z,i)))],i=0..99)],datatype=integer[4]);
(Sqrfree(LinearAlgebra:-Modular:-CharacteristicPolynomial(2,A,y)) mod 2)[2,1,1]
end:
CodeTools:-Usage(seq(MinPolyGF(F:-`^`(z,k),x),k=1..1000)):
memory used=0.79GiB, alloc change=27.81MiB, cpu time=19.10s, real time=19.23s
</pre>
<p>It works even with rather large powers of z,</p>
<pre>n:=(2^100-1)/3:
use F in MinPolyGF(z^n,x) end;
2
x + x + 1
</pre>
<p>DuncanA suggested an interesting idea in that thread that a minimal polynomial of an element b of F can be produced as a product of (x-b_i) where b_i are algebraic conjugates of b in F, which can be obtained in F by repeating usage of the Frobenius map.</p>
<p>The procedure for finding such conjugates can be written as</p>
<pre>AConj:=proc(x) local A,i,y;
A:=Array(1..100);
A[1]:=x;
y:=F:-`^`(x,2);
for i from 2 while x<>y do
A[i]:=y;
y:=F:-`^`(y,2);
od;
A[1..i-1]
end:
</pre>
<p>It is efficient,</p>
<pre>CodeTools:-Usage(seq(AConj(F:-`^`(z,k)),k=1..1000)):
memory used=221.40MiB, alloc change=0 bytes, cpu time=1.90s, real time=1.92s
</pre>
<p>However, expanding the product of (x-b_i) with b_i being such conjugates, takes a rather long time and uses a lot of memory,</p>
<pre>minpolGF:=proc(x,y:=_X)
local i;
Expand(mul(y-eval(F:-ConvertOut(i),_Z=a),i=AConj(x))) mod 2
end;
CodeTools:-Usage(seq(minpolGF(F:-`^`(z,k)),k=1..10)):
memory used=10.59GiB, alloc change=2.62MiB, cpu time=4.67m, real time=4.69m
</pre>
<p>_______________<br> Alec Mihailovs, PhD</p>121576Sun, 12 Jun 2011 19:42:17 ZAlec MihailovsAlec MihailovsA Long-Short 7 Asset Efficient Frontier
http://www.mapleprimes.com/posts/100338-A-LongShort-7-Asset-Efficient-Frontier?ref=Feed:MaplePrimes:Tagged With efficient
<p>restart:<br>with(LinearAlgebra):<br>with(ArrayTools):<br>with(Statistics):<br>randomize(): <br>with(plots): <br>with(combinat): <br><br>n := 100:<br>nstock := 7: <br>corr := .8: <br><br>R := Matrix(nstock, nstock, proc (i, j) options operator, arrow; `if`(i = j, 1, corr) end proc):<br>CD := Matrix(LUDecomposition(evalf(R), 'method' = 'Cholesky'), datatype = float[8]):<br><br>ev := [seq((1/5)*(rand(-3 .. 4))(), i = 1 .. nstock)]:<br>st := [seq((rand(1 .. 2))(), i = 1 .. nstock)]: <p>restart:<br>with(LinearAlgebra):<br>with(ArrayTools):<br>with(Statistics):<br>randomize(): <br>with(plots): <br>with(combinat): <br><br>n := 100:<br>nstock := 7: <br>corr := .8: <br><br>R := Matrix(nstock, nstock, proc (i, j) options operator, arrow; `if`(i = j, 1, corr) end proc):<br>CD := Matrix(LUDecomposition(evalf(R), 'method' = 'Cholesky'), datatype = float[8]):<br><br>ev := [seq((1/5)*(rand(-3 .. 4))(), i = 1 .. nstock)]:<br>st := [seq((rand(1 .. 2))(), i = 1 .. nstock)]: <br>A := Matrix([seq([Sample(RandomVariable(Normal(ev[i], st[i])), n)], i = 1 .. nstock)]):<br>B := Matrix(Transpose(Multiply(CD, A)));<br><br>ap := choose([seq(i, i = 1 .. nstock), seq(-i, i = 1 .. nstock)])[2 .. numbcomb([seq(i, i = 1 .. nstock), seq(-i, i = 1 .. nstock)])]:<br><br>for i to nops(ap) do <br><br>PR[i] := add(`if`(ap[i][j] > 0, 1, -1)*Array(Column(B, ap[i][j])), j = 1 .. nops(ap[i])):<br><br>EVV[i] := ExpectedValue(PR[i]):<br>STT[i] := StandardDeviation(PR[i]) <br><br>end do:<br><br>pointplot([seq([STT[i], EVV[i]], i = 1 .. nops(ap))], color = COLOR(RGB, rand()/10^12, rand()/10^12, rand()/10^12), thickness = 3, symbol = solidcircle, symbolsize = 10);<br></p>
<p> </p>
<p><a href="/view.aspx?sf=100338/316877/LS.jpg"><img src="/view.aspx?sf=100338/316877/LS.jpg" alt=""></a></p>100338Mon, 20 Dec 2010 16:48:17 Zalex_01alex_01