## Parallel computing in maple...

HI,

Can anyone suggest the tutorial or good examples for parallel computing in maple.

## Computing a complex residue...

Greetings to all.

With the following matter I am betting on there being a simple mistake on my part due to fatigue owing to a challenging session of intense computing. The following link at Math.Stackexchange.Com points to a computation involving complex residues. Consult the link for additional details.

I usually verify my computations with Maple, I did the same this time. Thereby I happened on a curious phenomenon which I have documented below. Please study the session data provided, I believe it speaks for itself.

```user@host:~\$ math
Mathematica 10.0 for Linux x86 (64-bit)

In[1]:= Residue[z^2/(z^4 + 2*z^2 + 2)^2, {z, 2^(1/4)*Exp[3*Pi*I/8]}]

1/8      1/4
(-1)    ((-1)    + Sqrt[2])
Out[1]= ----------------------------
1/4      1/4           3
16 2    ((-1)    - Sqrt[2])

In[2]:= N[%]

Out[2]= 0.117223 - 0.0083308 I

In[3]:=
user@host:~\$ maple
|\^/|     Maple 18 (X86 64 LINUX)
._|\|   |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2014
<____ ____>  Waterloo Maple Inc.
|       Type ? for help.
> residue(z^2/(z^4 + 2*z^2 + 2)^2, z=2^(1/4)*exp(3*Pi*I/8));
0

> quit
memory used=0.9MB, alloc=8.3MB, time=0.07
user@host:~\$
```

I am looking forward to learning what the correct syntax is to get the residue in this case and I hope I can assist other users who might have run into the same problem. I will cancel the question should it turn out to be trivial and of little potential use to the community.

Best regards,

Marko Riedel

Post Scriptum. Being a programmer myself I would be curious to learn more about the algorithms that are deployed here and how and why they did not succeed.

## Memory inflation in computations...

Hi guys,

I have written a program in Maple 2016 (Windows 7) made of two parts :

1. An initialization step where a formal system of algebraic equations (some non linear) is built
Let S(U, P) this system, where U denotes a set of unknowns and P a set of parameters (see step 2 below)
2. An iterative step where this system is solved with respect to U for different values of parameters P
This loop has to be executed N times for values P1, ..., Pn, ... of P

I observe that the size of the memory (bottom right of the Maple window) inflates as the value of n increases.

I was able to isolate in the loop corresponding to step 2, the procedure MyProc I wrote which is responsible of this memory inflation.
Now I would like to manage this inflation (typically the memory size grows up to 3 GiB for n about one thousand) because of its very negative effects on the computational time (probably Maple does spend a lot of time in swapping operations).

Suspecting the remember process to be the source of this problem, I tried simple tricks such as

• systematically write   > quantity := 'quantity';   for fome intermediate quantities
• use forget  : for example MyProc contains a call to fsolve and,  after "local" declarations, I inserted  the command  forget(fsolve)
• in the the loop over n,  I even inserted the command forget(Myproc).

None of these tricks was to some extent efficient to contain the memory inflation.

I suppose it is a very common situation that people who use to develop code are familiar with. So maybe some of you could provide my some advices or move me towards "strategies" or "methodologies" to prevent this situation ?
My purpose here is not to ask you to solve my problem, but rather to ask youy to give me hints to be able to manage such kind of situations by myself.

Maybe this question is unorthodox and doesn't have its place here ?
It that case please let me know.

PS : it would be very difficult for me to provide you the code : if it is a necessary condition for you to help me, just forget it, I will understand

## Huge memory usage...

I am faced by the problem where I used Grid:-Seq()---locally---to do some long time computation and I am faced by the exhaustion of memory problem. I think the problem itself is related to the memory management in maple.

So the problematic function is

# Procedure: ComputeEventsCTypeGrid
#   Compute events such that three quadrics intersects in a point.
#
# Parameters:
#   Q          - a set of quadrics
#
# Output:
#   Indexes of quadrics which intersect in a point.
# TODO:
#  - Memory
#  - Cleanups
ComputeEventsCTypeGrid := proc( Q )
local s, cType, i, j, k, rootNb, univ, sys;
s := proc (i, j, k)
sys := [ Q[i], Q[j], Q[k] ];
univ := PolynomialIdeals[UnivariatePolynomial]( indets( sys )[1], sys );
if not type( univ, constant ) then
rootNb := nops(select(proc(x)op(x)[2]>0;end proc,RootFinding:-Isolate( univ, [ op( indets(univ ) ) ] )) ):
if rootNb > 0 then
return [ univ, rootNb, sys ];
end if:
end if:
end proc;
cType := [Grid:-Seq(seq(seq(s(i,j,k),k=j+1..nops(Q)),j=i+1..nops(Q)),i=1..nops(Q))];
return cType;
end proc:

A dump from top after calling ComputeEventsCTypeGrid for some data(total amount of memory on this machine is 251G + 48G swap)

VIRT    RES    SHR S  %CPU %MEM     TIME+

33.007g 0.031t   3676 S   0.0 12.5   2606:20
31.137g 0.029t   3436 S   0.0 11.7   2274:34
8645756 4.984g   2840 S   0.0  2.0  32:06.40
28.798g 0.026t   1968 S   0.0 10.7   1821:16
26.650g 0.024t   1968 S   0.0  9.8   1520:54
25.346g 0.023t   1968 S   0.0  9.2   1236:44
23.296g 0.021t   1968 S   0.0  8.4   1004:52
20.498g 0.018t   1968 S   0.0  7.4 790:30.81
16.799g 0.014t   1968 S   0.0  5.9 625:28.12
15.011g 0.013t   1968 S   0.0  5.2 469:36.27
7678444 4.149g   1968 S   0.0  1.6 104:34.22
6734804 623904   1968 S   0.0  0.2  73:13.13
4327420 132516   1968 S   0.0  0.1  24:11.51
3420712 111336   1968 S   0.0  0.0  11:26.16
13.671g 0.011t   1964 S   0.0  4.6 380:15.13
11.771g 9.831g   1964 S   0.0  3.9 274:25.59
9936056 7.769g   1964 S   0.0  3.1 201:13.94
8805512 3.394g   1964 S   0.0  1.3 148:09.53
5077056 1.500g   1964 S   0.0  0.6  42:19.29
2384784  82040   1832 S   0.0  0.0   3:56.57

Size of output data calculated with

> length(sprintf("%m", eval(cType)));

> 326260610

Also, I called gc() at the end of the computations but memory allocated by instances of mserver were not released. Does it mean gc() should be called from each instance separately? My final point is that I have to run some other calculations for different and bigger dataset (It will probably take 2 days to finish -- Q has around 700 polynomials of degree 2) and for this moment I cannot do this because I've gotten an error about not enough amount of memory.

## evaluating forever......

hello people

I have this computation which has to do with my undergraduate project and each time I compute some work (vary parameters), it seems to evaluate forever. although my computer isn't recent and has 2GB of RAM the computation didn't seem to me as much of a task for it. computation works fine with some parameters as 0 but the moment I change it to a natural number, it evaluates forever.

Is there anyway I could speed up computation in maple? or do I just need a faster computer? but I have a dead line for next week. can I upload my worksheet for someone here to help me execute?

## Tensor Computations in Maple...

Hello every one.

I want to do some tensor computations in maple in a specified coordinate system but I don't know how! As an example I ask the follwing question.

Consider a second order symmetric tensor "A". I want to compute the components of "curl(curl(A))" in cylinderical coordinates. How should I do this in maple?

This is related to a famous equation in elasticity known as "small strain compatibility" equation.

Thanks for the help

## Problem with naief discrete logarithm algorithm...

Dear mapleprimes users,

I have a problem concerning this function:

Naief := proc(A::integer,B::integer, p::posint)
local x, a:= A mod p, b:= B mod p;

for x from 1 to p-1 do
if a^x mod p = b then return x end if
end do;
print(¨No solution.¨)

end proc

It works fine for what it should do, finding x for a^x = b mod p by inserting x from 1 to p-1 until it finds an
apprioperate x.

My problem is concerning its computation time, which I like to calculate with:

Codetools:- Usage(Naief(a,b,p), output = [cputime], quiet, iterations= 2^12)

The problem is that keeps repeating

alot even when a,b and p are immensely huge. I don`t know how to fix it, because I need real CPUtimes which increase
a,b and p increase. I get the idea that the values of the CPUtime are not realistic.

Thanks for the help!

## Error in solve function in Maple 18.02...

Dear friends,

Recently I was surprised when discovered the following error in using the function solve. If I run the simlest example from the help system for the first time (or after restarting), the following error occurs:

If I run this example repeatedly, this brings the following:

Previously in earlier versions I used solve many times for very complex computations and have never seen something similar.

Any suggestions are welcomed.

## How do I increase the memory allocation in Maple?...

Hi,

I am trying to find the inverse of 8x8 generic symbolic matrix. Everytime I evaluate the program I get the following error:

Error, (in expand/bigprod) Maple was unable to allocate enough memory to complete this computation. Please see ?alloc

Can anyone guide me how to increase the memory allocation? And would that solve the problem for me?

Any help is appreciated.

Thanks!!

## New record computation

I would like to announce a new unofficial record computation of the MRB constant that was finished on Sun 21 Sep 2014 18:35:06.

I really would like to see someone beat it with Maple!

It took 1 month 27 days 2 hours 45 minutes 15 seconds. I computed 3,014,991 digits of the MRB constant, (confirming my previous 2,00,000 or more digit computation was actually accurate to 2,009,993 digits), with Mathematica 10.0. I Used my version of Richard Crandall's code:

____________________________________________________________________________

(*Fastest (at MRB's end) as of 25 Jul 2014.*)

DateString[]

prec = 3000000;(*Number of required decimals.*)ClearSystemCache[];

T0 = SessionTime[];

expM[pre_] :=

Module[{a, d, s, k, bb, c, n, end, iprec, xvals, x, pc, cores = 12,

tsize = 2^7, chunksize, start = 1, ll, ctab,

pr = Floor[1.005 pre]}, chunksize = cores*tsize;

n = Floor[1.32 pr];

end = Ceiling[n/chunksize];

Print["Iterations required: ", n];

Print["end ", end];

Print[end*chunksize]; d = ChebyshevT[n, 3];

{b, c, s} = {SetPrecision[-1, 1.1*n], -d, 0};

iprec = Ceiling[pr/27];

Do[xvals = Flatten[ParallelTable[Table[ll = start + j*tsize + l;

x = N[E^(Log[ll]/(ll)), iprec];

pc = iprec;

While[pc < pr, pc = Min[3 pc, pr];

x = SetPrecision[x, pc];

y = x^ll - ll;

x = x (1 - 2 y/((ll + 1) y + 2 ll ll));];(*N[Exp[Log[ll]/ll],

pr]*)x, {l, 0, tsize - 1}], {j, 0, cores - 1},

Method -> "EvaluationsPerKernel" -> 4]];

ctab = ParallelTable[Table[c = b - c;

ll = start + l - 2;

b *= 2 (ll + n) (ll - n)/((ll + 1) (2 ll + 1));

c, {l, chunksize}], Method -> "EvaluationsPerKernel" -> 2];

s += ctab.(xvals - 1);

start += chunksize;

Print["done iter ", k*chunksize, " ", SessionTime[] - T0];, {k, 0,

end - 1}];

N[-s/d, pr]];

t2 = Timing[MRBtest2 = expM[prec];]; DateString[]

Print[MRBtest2]

MRBtest2 - MRBtest2M

_________________________________________________________________________.

I used a six core Intel(R) Core(TM) i7-3930K CPU @ 3.20 GHz 3.20 GHz with 64 GB of RAM of which only 16 GB was used.

t2 From the computation was {1.961004112059*10^6, Null}.

## Numerical Computation Performance...

I have written a code that computes the fourier-bessel series of a function over the period [a,b].
When I wanted to get some numerical results, I noticed that it takes lots of time for maple to numerically compute the coefficients of the series. Each coefficient of the series is expressed in terms of some integrals that I was expecting maple to compute them in few seconds, however, when  I want to compute "N=100" terms of the series, it takes lots of time.

I was wondering if there is any way to boost up the numerical computation time. I will appreciate any help.

Below you can find my code.

Example_2.mw

Many many thanks for your attentions! :)

## Possible to run many sheets on a machine?...

Say I have

a.mpl

b.mpl

c.mpl

each of them can be ran seperately. While I am running a single file, it looks like that the machine is not "using" too much computation power. I wonder if it's possible to run multiple at the same time ?

My CPU is i7 940X, with 4 dual core processors, so it has 8 threads.

I know that the GUI can run multiple worksheets seperately, but if in one of the worksheet, i click "run all" (!!! botton),  I will have to run each line separtely by clicking one at a time.

Is there a better way to do this? What's the best way to do this? I hope to somehow 'maximize' the full use of my CPU (without changing the code).

casper

## How to measure CPU time used by a computation and ...

Hello.

Two related questions: I'd like to measure the CPU time used by a computation. Should I use with(CodeTools)? or use  time[real]? What would be the most accurate way to measure the CPU time used by one call, say dsolve()?

Also, How would one return both the result of the computation and the time used in one call so that one does not have to make two separate calls: to obtain the result and to obtain the CPU time?

Example:

restart;
with(CodeTools):
ode:=2*a*x^3*y(x)^3+2*x*y(x)+diff(y(x), x);
result:=Usage(dsolve(ode=0,y(x)),output='cputime');

Gives result:=0.141 while

restart;
ode:=2*a*x^3*y(x)^3+2*x*y(x)+diff(y(x), x);
result:=time[real](dsolve(ode=0,y(x)));

Gives result:= 0.145

But in both cases, I have to make another call to get the result of the DSolve in this example. result:=dsolve(ode=0,y(x)); which I'd like to avoid if possible.

I am using Maple 18

## Changing a Global Parameter for each evaluation in...

I have a rank 1 array M of 1000 values.

I want to apply a function f on each value of M and its location giving,

[f(1,M[1]), f(2,M[2]), ... , f(1000,M[1000])]

is it possible to get this using map or map2 or map[n] or maptype (without using seq since its slowing down computation).

inotherwords can i access the member location inside a map evaluation?

## Slides of VII Workshop 2014

Maple 17

Slides of the presentation at the VII Workshop Fast Computational and Applied Mathematics developed in graduate school at the National University of Trujillo. January 8, 2014.

Visualización_Geomét.pdf

L. Araujo C.

 1 2 3 Page 1 of 3
﻿