AmusingYeti

165 Reputation

8 Badges

9 years, 323 days

MaplePrimes Activity


These are questions asked by AmusingYeti

I am solving a matrix eigenvalue problem, and have found a way to make the matrices very sparse by a set of conditions x=x', y=y' and z=z'. If these are satisfied then the matrix element will be >0. If any one of them is not satisfied, then the matrix element becomes zero; hence a sparse matrix is formed. Mathematically in Maple this can be represented as such:

ME*KroneckerDelta[x,xp]*KroneckerDelta[y,yp]*KroneckerDelta[z,zp];

Where ME represents the matrix element and xp, yp, zp represent the prime notation . I apply this form within a C++ routine which I am extracting the matrices from into Maple where I am looking to modify them to experiment with an extension of the program.

The matrices I read into Maple have had the Kronecker delta functions applied, however Is there a simple way to reverse the effect of the Kronecker delta functions with the Matrix in Maple and return the Matrix equivalent to just ME without the product of kronecker delta functions?

-Yeti

I am not unfamiliar with the Wolfram syntax but also not very good with it, and there is a particular element in a Mathematica code I have been given which I do not entirely understand how to efficiently write in Maple. The basic idea is to read in a list of expressions from an external file (LIST) and process the non zero elements and assign them to a function (COEF) which can be called later on. Here is the Mathematica exert:

k = 0;
i = 0;
a = b = \[Theta];
Do[k = k + 1; KK = LIST[[k]]; 
  If[KK =!= 0, i = i + 1; ff = Factor[KK]; 
   COEF[x,y, z, l_, m_, n_] = ff], {z, -2, 
   2}, {y, -2, 2}, {x, -2, 2}];

The LIST has the following form and only contains l, m and n and another factor E which is left undefined for now. It does not contain x, y or z. The LIST can contain any number of terms depending on the problem. Here is an example:

LIST={0, 0, 0, 0, 0, 0, 0, a^2 b m (-1 + n) n (a^2 + b^2 - 2 E), ... ,0,0, a^3 n(l+1+m) ... }

So the Do loop cycles through the LIST and extracts out the non zero terms. What I am unsure about is how it is looping over x,y and z when they do not appear in the LIST at all. I assume it is attaching a x,y,z combination to each COEF and they can be called like this:

COEF[0,1,1,0,2,3]

For the instance of when x=0, y=1, z=1, l=0, m=2 n=3. Is this correct? What would be the best way to replicate this in Maple?

- Yeti

I have written a C++ program which I feed in an input from Maple which has been converted using the CodeGeneration package in Maple and stored in a text file. For it to be processed in C++ I need to remove the cg = at the start of the Maple output expression. An example of this is as follows:

C(x^2+y^2+z^2);

cg = x * x + y * y + z * z

C++ cannot process the cg= at the start of the string and so I have found ways around it by using Bash or C++ itself to remove or ignore the cg = but I was wondering if it was possible to just not have Maple print it to begin with?

- Yeti

I have recently acquired Maple 2016 and wanted to see how its numerical integration compared to previous version (in this instance, 2015 and 18). This integration is a tougher problem than the usual "textbook" case using a well behaved function. The integrand presented in the worksheet below is a small example but it can get much larger.

I am calculating a triple integral numerically from a function read in from a file which contains Laguerre polynomials. Some simplifications are done first and then that is fed into the integration. In the example script below the input has been put into the program to make it simpler.

So far it appears Maple 18 is faster than 2015 (in this case anyway) and 2016 does not appear to like the syntax I am using even though it runs fine on 18 and 2015 (it does not like the simplify(expr1,LaguerreL) or sqrt parts).

Looking at the stats of the calculation runs:

Maple 18:

memory used=0.52MiB, alloc change=0 bytes, cpu time=20.33s, real time=20.49s, gc time=0ns

answer = 0.160262735437965


Maple 2015:

memory used=350.84KiB, alloc change=0 bytes, cpu time=28.77s, real time=29.24s, gc time=0ns

answer = 0.160262735437309

What is interesting is that Maple 18 is allocating more memory in order to solve the problem compared to 2015. Does anyone have any ideas why this is occuring? Also has there been a syntax change from 2015 -> 2016 which I have not been aware of. Is there a different way to write the script to run in 2016?

Here is the worksheet:

Maple_numeric_speed.mw

Thank you in advance

- Yeti

Hello Mapleprime users

I am having an issue with a numerical integration calculation. I have a large(ish) polynomial integrand and need to apply two integrations which I am using the _cuhre method for. See attached the minimum working example file.

Numerical_integration_HF.mw

Firstly some simplifications are done to the integrand and then a basic for loop which calculates the integration for r from 0 to 20 in steps of 0.1. The issue occurs when the loop hits r~2.5 (on my machine, Maple 2015, i5, 16GB ram). Up to that point the calculation is steady with the following stats per point calculated:

memory used=87.59MiB, alloc change=0 bytes, cpu time=3.45s, real time=3.15s, gc time=439.16ms


Then when the calculation gets to ~2.5 it just hangs and will not calculate past it. Any ideas as to what is going on here?

Any help would be appreciated with this issue.

Thank you in advance

Yeti

 

 

1 2 3 4 5 Page 3 of 5