## 260 Reputation

10 years, 139 days

## A link to my file...

@Carl Love

https://www.dropbox.com/s/s07f7q8tltzy6tr/MatrElems.mw

## test exampe with Grid:-Seq...

@Carl Love

The biggest matrix psi1(i).H.psi2(j) with wich I'd like to cope with is 3060 \times 3060. I need to get the lowest eigen value and the corresponding eigenvector of this matrix.  However, the matrix of size 276 \times 276 will give me some useful information too. Matrix psi1(i).H.psi2(j) is a sparse matrix. Is this explanation sufficient or should I give more details about psi1(i), H, psi2(j) so that you could help me?

I've tried to use Grid:-Seq but Maple gives an error. A test example of my program is attached to my reply. Two procedures MatrElems and MatrElemsGrid are the key procedures for calculations. Procedure MatrElemsGrid is the same as MatrElems but uses Grid:-Seq instead of seq.

MatrElems.mw

## elem must be a thread-safe procedure...

@Carl Love

Thank you for comment! I guess that it'll be good for those using Threads in their calculations. Unfortunately, I couldn't find it out myself due to that simple reason that I carried out my tests with

elem := (i,j)->BesselJ(0, i)*BesselJ(1, i)*BesselJ(0, j)*BesselJ(1, i)

which is not a thread safe procedure. My tests with that procedure gave me results which, as I now understand, have no sense.

elem procedure that I need to use in my work is not thread safe too. My elem(i,j) is psi1(i).H.psi2(j) (matrix element of the Hamiltonian of some many-body quantum system). So, unfortunately, threads are useless in my case.

## Now it is ok...

@Carl Love
In my real code elem is a combersome procedure, so using Threads is appropriate.

I guess the declaration

A:= Matrix(N, N, shape= symmetric);

is excessive and I suppose that

A:= Matrix(N, N);

will work a bit faster. I've tried to do a test that could prove or disaprove my assumption, but test gave strange results and I cannot confidently assert that second declaration provides faster calculations.

One moment is still unclear. Maple says that A is Fortran_order. Fortran uses Column-major order, therefore it is natural to assume that

.....
for j to N do
end do:

will work faster. However it is slower. Why?

Several derivative approaches can be suggested. It would be natural to assume that the following one is optimal

A := Matrix(N, N, shape = symmetric);
for i to N do
A[i, i .. N] := <Threads:-Seq(elem(i, j), j = i .. N)>
end do:

but tests could not prove it.

@Carl Love

A result with N=2^2 and elem(i,j)=i*j:

## A Treatise on the Theory of Bessel Funct...

Hi. I guess you have to have a look in book

"A Treatise on the Theory of Bessel Functions" (Cambridge Mathematical Library)
by G. N. Watson.

## Maple is ok...

In Fortran:

a) input:

f = exp(-x**2)*exp(2.0_nag_wp*x)

output:

d01amf example program results   ** Round-off error prevents the requested tolerance from being achieved:      EPSABS =  0.0E+00  EPSREL =  1.0E-12.   ** ABNORMAL EXIT from NAG Library routine D01AMF: IFAIL =     2   ** NAG soft failure - control returned   epsabs -      absolute accuracy requested =  0.00E+00   epsrel -      relative accuracy requested =  0.10E-11      result -    approximation to the integral =       NaN   abserr -   estimate of the absolute error =       NaN   iw(1)  -      number of subintervals used =   20

b) input:

f = exp(-x**2+2.0_nag_wp*x)

output:

d01amf example program results   epsabs -      absolute accuracy requested =  0.00E+00   epsrel -      relative accuracy requested =  0.10E-11      result -    approximation to the integral =   4.81803   abserr -   estimate of the absolute error =  0.33E-11   iw(1)  -      number of subintervals used =    8So, there is really trouble with NAG, not with Maple.I guess that Axel Vogt is right. NAG-integration function can not recognize the damping of the final result for exp(-x**2)*exp(x) and evaluates each of the factors separately, where second factor diverges.However, it is not always possible "to prepare the task for numerics", as Alex recomends. For instance, you have to calculate the coefficients of Hermite-Fourier series. But, as it became clear to me, CAS (in particular Maple) have advanteges over Fortran or C! We can really 'prepare' the task for numerics in CAS!

Simplify command fixes the problem:

2.275875794

Thank you for help!

## @Carl Love Good idea. I'll check it...

@Carl Love
Good idea. I'll check it with Fortran.

## However...

@Carl Love

Let's add digits option to the integration.

u := x -> Int(exp(-(xi-x)^2)*exp(xi), xi = -infinity .. infinity, method = _d01amc, digits = 5);
evalf(u(0.));

Round-off error prevents the requested tolerance from
being achieved:  epsabs = 5.0e-008,  epsrel =  5.0e-005.

u := x -> Int(exp(-(xi-x)^2)*exp(xi), xi = -infinity .. infinity, digits = 5);
evalf(u(0.));

2.2759

u := x-> Int(exp(-(xi-x)^2+xi), xi = -infinity .. infinity, method = _d01amc, digits=5);
evalf(u(0.));

2.2759

Are you still think that it is OK with the Maple implementation of the NAG's method = _d01amc?

## layout & triggering...

@acer

I'd like to create Sliders laid out in a tabe and triggered by action when content of the Textarea change. I need to have a possibility to destroy sliders too.

Andriy

## thank you...

@Carl Love
There is no significance to the brackets. It is exactly what I need. Thank you!

## Suggestion...

Hi.
Do persons with nicknames "admin" and "Maplesoft" take part in the competition? If no, isn't it better to move their apps. from the "Mobius@admin" group to "public" group?

## Agree...

"It appears as though the pending embedded component actions are executed before the response to the dialog"

I agree.

## The problem is solved but some issues ar...

@Joe Riel Conditional around

if assigned(Actions) then ... end if;

solves the problem. However, some points are still unclear to me. You say that "Maple first tries to execute any code in the startup region. Because that is not enabled, it doesn't occur." Why is not it enabled? I have a startup code where Actions module is described.

you say: "If you do not want to allow the startup region to execute automatically..." I want to allow the startup region to execute automatically. Does AutoExecute Security Level option 'Warn once for each worksheet' disable autoexecution?

 1 2 3 4 5 6 7 Page 3 of 10
﻿