## how i can reduce the runtime of the program ?...

Asked by:

hi..how i can rewrite section of this code as another form i,e ''for section''

I have a lot of line as this and runnig cise is time consuming.

is there another way to write this section in order to the runtime of the program is reduced??

thanks

 > restart;
 > with(LinearAlgebra):
 > with(VectorCalculus):
 > #Digits:=5: k:=6:
 > l:=0:
 > h:=1:
 > m:=4:
 > n:=4:
 > l1:=2*h:
 > l2:=2*h:
 > N:=0.5:
 > nu:=.3:
 > E_m:=70e9:
 > E_c:=380e9:
 > rho_m:=2702:
 > rho_c:=3800:
 > lambda_m:=nu*E_m/((1+nu)*(1-2*nu)):
 > lambda_c:=nu*E_c/((1+nu)*(1-2*nu)):
 > mu_m:=E_m/(2*(1+nu)):
 > mu_c:=E_c/(2*(1+nu)):
 > with(orthopoly):
 > for i from 0 to 5 do: L(i):=sqrt((2*i+1)/2)*P(i,z): end do:
 > Z:=rho_m+(rho_c-rho_m)*((1/2)+(z/h))^N;
 (1)
 > U:=lambda_m+(lambda_c-lambda_m)*((1/2)+(z/h))^N;
 (2)
 > S:=mu_m+(mu_c-mu_m)*((1/2)+(z/h))^N;
 (3)
 > d:=Matrix([[0,0,0,0,0,0,0,0],[sqrt(3),0,0,0,0,0,0,0],[0,sqrt(15),0,0,0,0,0,0],[sqrt(7),0,sqrt(35),0,0,0,0,0],[0,sqrt(27),0,sqrt(63),0,0,0,0],[sqrt(11),0,sqrt(55),0,sqrt(99),0,0,0],[0,sqrt(39),0,sqrt(91),0,sqrt(143),0,0],[sqrt(15),0,sqrt(75),0,sqrt(135),0,sqrt(195),0]]);
 (4)
 >

 >
 (5)

Download for.mw

## Maple 2017 on a Microsoft surface pro 4 touch...

by: Maple 2017

The purpose of this post is to review how well-designed Maple 2017 GUI is for a Microsoft surface pro 4 tablet touch screen with windows 10 pro (64-bit) and to determine the performance of Maple 2017 on my tablet which has a m3 CPU with a 0.9 GHZ base frequency and 4 GB RAM.

First, my experience is that 4 GB of RAM is far from enough. Under heavy load I have had problems before on other software with 4 GB of RAM. 68 % of my RAM and 41% of the CPU is already gone by simply running Maple and my web browser at the same time before I have even instructed Maple to do any calculations.

I think a tablet with at least 8 GB of RAM would be preferred. If you only want to use Maple as an expensive calculator then you would most likely not even need 4 GB of RAM. I find that the surface pro 4 to be overpriced for the hardware it provides. I think eve windows 10 tablet http://eve-tech.com/ with up to 16 GB of RAM and with a much cheaper price looks much more promising than the Microsoft surface pro 4. When I use the surface pro 4 with word 2016 and the reference manager zotero word plugin I sometime notice a trailing line when I sweep up or down in a document with a lot of references which I suspect is because of the low amount of RAM. When I played with Maple 2017 on my surface pro I noticed the same trailing line which again indicates to me that there is not enough RAM. However, I am not certain that low RAM is the cause of such problem.

Secondly, I managed to increase the size of the Maple icons under the File, Edit etc. menu so now they have a perfect size for a touch screen tablet. Very cool!

However, as you can see words in the text menu File, Edit etc. are way too small for a touch screen tablet. There is a lot of room to the right so the words could easily be increased in size. I am also a missing a menu item called maplet where you can attach your own maplets for easy access. It appears that Maple 2017 GUI has not been designed with a touch screen tablet in mind. I wish the words in the text menu File, Edit etc. would have increased when I increased the size of the icons. The text and icons in the sidebar are also way too small for a touch screen tablet. The name of the open tabs is also to small and x that you tap on to close the worksheet is also to small. It is almost impossible to close a worksheet because the x is so small.

I thinks there are ways in windows 10 to increase the text size in the menus but I have only been able to increase the text size and icon size for all software at the same time. Since, Maple is more or less the only software that I have where the menu text is too small this is not an optimal solution.

The table of content for Maple help files also has too small text as seen in the below picture. However, the biggest problem is not the small words it is the row spacing of the table of content. Some of the words appear almost to be on top of each other. I think the row spacing need to be increased. The text within the help files itself displays beautifully and is in the perfect size.

Another problem is that when you swipe up or down on the touch screen you dont go up or down in the maple document. You just highlight text as seen in the picture below. This needs to be fixed. Highlighting should be done by a long tap on the screen as in word 2017 on a touch screen devices.

The norm today might be to use Maple on a desktop computer or on a laptop but I am convinced that in the future touch screen tablet will become more and more powerful making them an excellent computers to run Maple on because they are so light and portable. I think Maplesoft must have this in mind when they design the GUI.

Now to test the performance of Maple 2017 on my tablet I decided to generate 1 000 000 random number and see how long it takes. Since I dont have a benchmark it becomes very hard to comment on how fast maple 2017 is on my tablet but I am hoping that someone can run the same code on their machine and comment on this post so we can get a benchmark.

Download AFP.mw

## Using Linsolve for large systems of linear equatio...

Asked by:

Hi,
I am solving large systems of linear equations (mod 2) which are of this form ,
systems:= {0 = f[[1, 4]]-f[[1, 3]], 0 = f[[1, 5]]-f[[1, 3]], 0 = f[[1, 5]]-f[[1, 4]], 0 = f[[1, 6]]-f[[1, 3]], 0 = f[[1, 6]]-f[[1, 4]], 0 = f[[1, 6]]-f[[1, 5]], 0 = f[[1, 7]]-f[[1, 3]], 0 = f[[1, 7]]-f[[1, 4]], 0 = f[[1, 7]]-f[[1, 5]], 0 = f[[1, 7]]-f[[1, 6]], 0 = f[[2, 4]]-f[[1, 3]], 0 = f[[2, 5]]-f[[1, 3]], 0 = f[[2, 5]]-f[[1, 4]], 0 = f[[2, 6]]-f[[1, 3]], 0 = f[[2, 6]]-f[[1, 4]], 0 = f[[2, 6]]-f[[1, 5]], 0 = f[[2, 6]]-f[[2, 4]], 0 = f[[2, 6]]-f[[2, 5]], 0 = f[[2, 7]]-f[[1, 3]], 0 = f[[2, 7]]-f[[1, 4]], 0 = f[[2, 7]]-f[[1, 5]], 0 = f[[2, 7]]-f[[1, 6]], 0 = f[[2, 7]]-f[[2, 4]], 0 = f[[2, 7]]-f[[2, 5]], 0 = f[[3, 1]]-f[[1, 4]], 0 = f[[3, 1]]-f[[1, 5]], 0 = f[[3, 1]]-f[[1, 6]], 0 = f[[3, 1]]-f[[2, 7]], 0 = f[[3, 5]]-f[[1, 4]], 0 = f[[3, 5]]-f[[1, 5]], 0 = f[[3, 5]]-f[[2, 4]], 0 = f[[3, 5]]-f[[2, 5]], 0 = f[[3, 6]]-f[[1, 3]], 0 = f[[3, 6]]-f[[1, 4]], 0 = f[[3, 6]]-f[[1, 5]], 0 = f[[3, 6]]-f[[1, 6]], 0 = f[[3, 6]]-f[[2, 4]], 0 = f[[3, 6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]-f[[4, 7]], 1 = f[[6, 4]]-f[[4, 7]], 1 = f[[7, 1]]-f[[3, 7]], 1 = f[[7, 1]]-f[[4, 7]], 1 = f[[7, 1]]-f[[5, 7]], 1 = f[[7, 2]]-f[[4, 7]], 1 = f[[7, 3]]-f[[5, 7]], 1 = f[[7, 4]]-f[[5, 7]]};

I have been using msolve as follows; msolve(systems,2);  which returns NULL if there is no solution. This however takes a lot of my computer memory and also take a lot of time since the equations are very many.  I decided to try LinearSolve, but it doesn't give me any solutions even for the ones that I know that the solutions exist. My code was writen as follows:

systems:=as above..

vars := [f[[1, 3]], f[[1, 4]], f[[1, 5]], f[[1, 6]], f[[1, 7]], f[[2, 4]], f[[2, 5]], f[[2, 6]], f[[2, 7]], f[[3, 1]], f[[3, 5]], f[[3, 6]], f[[3, 7]], f[[4, 1]], f[[4, 2]], f[[4, 6]], f[[4, 7]], f[[5, 1]], f[[5, 2]], f[[5, 3]], f[[5, 7]], f[[6, 1]], f[[6, 2]], f[[6, 3]], f[[6, 4]], f[[7, 1]], f[[7, 2]], f[[7, 3]], f[[7, 4]]];

A,b:=GenerateMatrix(systems,var):
LinearSolve(A,b) mod 2;
what I'm I doing wrong? How can I make this fast and in such a way that the solution is computed without taking too much memory?

I also understand that LinearSolve returns the following when there is no solution, "Error, (in LinearAlgebra:-LinearSolve) inconsistent system
", in my case, if there is no solution, I don't want that error to be printed, but I want some variable (call it x) to be printed if a solution is found.

Any help is appreciated.

Vic.

## Using break to stop the entire computation...

Asked by:

Hi,

I would like to thank everyone who takes their time to respond to posts on this page. I have another question.

I have about 11 trillion lists that are of the form A shown below. The lists ofcourse have more elements than A (about 50 elements). What I want is to compute this value I call f, and the moment this value is found to be 1, we stop, and if all the values of f are 0, then we print(A). Here is my code, which has a problem and doesn't give me the result I want. How do I modify this so that if any value of f=1, then we stop, elif no 1 is found, we print just one value for A and not for every 0 produced?

with(ListTools);
A := [[1, 2], [1, 7], [5, 6], [1, 6], [1, 9], [6, 5], [9, 1], [2, 1], [7, 1], [6, 1], [5, 6]]; n := 9;
for i to n do for j to n do for k to nops(A) do if [i, j] = A[k] then a := Search([i, j], A); b := Search([j, i], A); if a < b then f := mod(b-a, 2); if f = 1 then break else print(A) end if end if end if end do end do end do;

Presently what I am doing is to Append all values of f into an Array and check that 1 is not an element of that Array. This is however very inconvenient since my lists are huge, and they are many, and we do not have to cpompute all the values of f once we come across a 1. Other than this, is there a way I can make my program run faster? Any suggestions are welcomed.

Thanks,

VIC.

## Maple 2015.0 : comparisons of cpu time between Win...

Asked by:

Hi everybody,

Until recently I was using Maple 2015.0 on this PC :

Windows XP
2 dual core proc Intel(R) Xeon(R) CPU E3-1225 V2 ; 3.19 GHz
64 bytes,
16 Go RAM

For two days now I am using Maple 2015.0 on this one

Windows 7
4 dual core proc Intel(R) Xeon(R) CPU 5-2637 V3 ; 3.50 GHz
64 bytes,
64 Go RAM

Comparisons of the running times for exactly the same code, consisting in 10000 independent Monte Carlo  simulations distributed over all the nodes (resp 4 and 8) give :

Windows XP :  504 sec  (with a variation of the order of  +/- 3s for different replicates)

Windows 7   :  343 sec  (with a variation of the order of  +/- 3s for different replicates)

The expected running time should be 504 * (3.2/3.5) * (4/8) = 230 s
(or 504 * (4/8) = 252 s if you neglect the acceleration due to the clock rate)
The realized running time (343 s) is thus at least  40% larger than the expected one.

Does anybody has already observed this kind of performance loss during XP -> 7 migration ?
Are there some comparisons of cpu times between Windows XP and 7 ?

Thank you all for sharing your own experience.

postscript : a NOTIONALexample of how the computations are distributed is given below

NbOfRuns := 10000:

# Data is a Matix(NbOfRuns, NbOfCols, …) constructed elsewhere

NbOfNodes := Grid:-NumNodes():
NbOfRunsPerNode := NbOfRuns / NbOfNodes:
for k from 0 to NbOfNodes do
FirstData := 1 + k * NbOfRunsPerNode:
LastData := (k+1) * NbOfRunsPerNode:
Grid:-Run(k+1, MyCode, [Data[FirstData..LastData, ..], …])
end do:

## Sparse Matrix Products in Maple

by: Maple

I thought I would share some code for computing sparse matrix products in Maple.  For floating point matrices this is done quickly, but for algebraic datatypes there is a performance problem with the builtin routines, as noted in http://www.mapleprimes.com/questions/205739-How-Do-I-Improve-The-Performance-Of

Download spm.txt

The code is fairly straightforward in that it uses op(1,A) to extract the dimensions and op(2,A) to extract the non-zero elements of a Matrix or Vector, and then loops over those elements.  I included a sparse map function for cases where you want to map a function (like expand) over non-zero elements only.

# sparse matrix vector productspmv := proc(A::Matrix,V::Vector)local m,n,Ae,Ve,Vi,R,e;  n, m := op(1,A);  if op(1,V) <> m then error "incompatible dimensions"; end if;  Ae := op(2,A);  Ve := op(2,V);  Vi := map2(op,1,Ve);  R := Vector(n, storage=sparse);  for e in Ae do    n, m := op(1,e);    if member(m, Vi) then R[n] := R[n] + A[n,m]*V[m]; end if;  end do;  return R;end proc:
# sparse matrix productspmm := proc(A::Matrix, B::Matrix)local m,n,Ae,Be,Bi,R,l,e,i;  n, m := op(1,A);  i, l := op(1,B);  if i <> m then error "incompatible dimensions"; end if;  Ae := op(2,A);  Be := op(2,B);  R := Matrix(n,l,storage=sparse);  for i from 1 to l do    Bi, Be := selectremove(type, Be, (anything,i)=anything);    Bi := map2(op,[1,1],Bi);    for e in Ae do      n, m := op(1,e);      if member(m, Bi) then R[n,i] := R[n,i] + A[n,m]*B[m,i]; end if;    end do;  end do;  return R;end proc:
# sparse mapsmap := proc(f, A::{Matrix,Vector})local B, Ae, e;  if A::Vector then    B := Vector(op(1,A),storage=sparse):  else    B := Matrix(op(1,A),storage=sparse):  end if;  Ae := op(2,A);  for e in Ae do    B[op(1,e)] := f(op(2,e),args[3..nargs]);  end do;  return B;end proc:

As for how it performs, here is a demo inspired by the original post.

n := 674;k := 6;
A := Matrix(n,n,storage=sparse):for i to n do  for j to k do    A[i,irem(rand(),n)+1] := randpoly(x):  end do:end do:
V := Vector(n):for i to k do  V[irem(rand(),n)+1] := randpoly(x):end do:
C := CodeTools:-Usage( spmv(A,V) ):  # 7ms, 25x fasterCodeTools:-Usage( A.V ):  # 174 ms
B := Matrix(n,n,storage=sparse):for i to n do  for j to k do    B[i,irem(rand(),n)+1] := randpoly(x):  end do:end do:
C := CodeTools:-Usage( spmm(A,B) ):  # 2.74 sec, 50x fasterCodeTools:-Usage( A.B ):  # 2.44 min
# expand and collect like termsC := CodeTools:-Usage( smap(expand, C) ):
 1 2 3 4 5 Page 1 of 5
﻿