sand15

882 Reputation

13 Badges

10 years, 277 days

MaplePrimes Activity


These are replies submitted by sand15

restart

kernelopts(version)

`Maple 2015.2, APPLE UNIVERSAL OSX, Dec 20 2015, Build ID 1097895`

(1)


ref: Programing_Guide_2023

pages 583-584

add_range := proc(lo, hi)

local i;

add( i, i = lo..hi );

end proc:

parallel_add_range := proc( lo, hi, n )

local i,step,d;

d := hi-lo+1;

step := floor( d/n );

Threads:-Task:-Continue( `+`, Tasks=[ add_range,

seq( [i*step+lo,(i+1)*step], i=0..n-2 ),

[ (n-1)*step+lo,hi ] ] );

end proc:

N := 3*10^7;

30000000

(2)

start := time[real]():

add_range( 1, N );

time[real]()-start

450000015000000

 

1.581

(3)

start := time[real]():

Threads:-Task:-Start( parallel_add_range, 1, N, 2 );

time[real]()-start

450000015000000

 

1.081

(4)

start := time[real]():

Threads:-Task:-Start( parallel_add_range, 1, N, 4 );

time[real]()-start;

450000015000000

 

.506

(5)

start := time[real]():

Threads:-Task:-Start( parallel_add_range, 1, N, 10000 );

time[real]()-start;

450000015000000

 

.536

(6)

 

Download Maple_PG2023_pp583-584.mw

About your Monte-Carlo simulatoin problem:
I use to do intensive MC simulations int he following specific context: some inputs X of a simulation code C are random variable and one is interested in assessing some statistics of the random output(s?) Y of C.

This problem is usually tackled by sampling X, running C over this sample, finally analyzing the induced Y sample. X sampling can be done through some strategy, in particular Monte-Carlo sampling (MCS).
MCS is largely used for a MC sample augmented by another MC sample is still a MC sample (specific properties MCS are conserved), opening the route to distributed computations, that is sampling+running on different cores/processors/machines.

This process is perfectly scalable meaning the sampling+running operation executed on P cores is exactly P times faster than executed on a single one (at least in theory for the OS of the machine host limits generally reduces the performance).
The time requires to gather the P partial simulations is general negligible

To do this I use to use the Grid package instead of the Threads one.

 @petit loup    @acer 

Sample(Normal(0, 1), [n, n])

@Jamie128 

So do you say that z = -2*M^2*sin(theta)^2 - 2*k*r^2?
What you need, I repeat myself, is a function r(theta, z) plot3d(r(theta, z), theta = a .. b, z = c .. d, coords = cylindrical)
and this expression of z doesn't make r uniquely defined:

restart
z = -2*M^2*sin(theta)^2 - 2*k*r^2;
r =~ [solve(%, r)]

 

 

 

it is said that

For alternate coordinate systems this is interpreted differently. For example, when using cylindrical coordinates, Maple expects the command to be of the following form: plot3d(r(theta, z), theta = a .. b, z = c .. d, coords = cylindrical)

What are r(theta, z) and z in your expression -2*M^2*sin(theta)^2 - 2*k*r^2?

Do you mean z = -2*M^2*sin(theta)^2 - 2*k*r^2?

What does your claim "where the function is greater than zero and where it is less that zero" mean given that ehe radius (r?) is to be always greater or equal to 0.



To complete @Christian Wolinski 's reply: f can be integrated provided alpha is an integer <= 1.
I guess that the reason why the WhittakerM function

In the attached file you will see that the integration can be done only (that's my hunch, not a mathematical proof) when
WhittakerM(a, b, 3/2*t) can be converted into elementary functions.
(
Maybe there exist some recurrence relation to integrate int(h(t)*WhittakerM(a, b, 3/2*t) , t), but I wasn't capable to find any.
More precisely I thought that one could take advantage that

diff(WhittakerW(p, q, 3/2*t), t);
                                                  /          3  \
                                       WhittakerW |p + 1, q, - t|
 3 /1   2 p\             /      3  \              \          2  /
 - |- - ---|  WhittakerW |p, q, - t| - -------------------------
 2 \2   3 t/             \      2  /               t            
          

).

When alpha is an integer > 1, the denominator GAMMA(2-alpha)=0 and f is undefined.

Whittaker.mw

@mz6687 

I'm sorry, but I don't understand a single word of what you're saying.
What is this 8x8 matrix you are now talking about?

BTW: is it you who deleted your last question or was it moved by someone else?

Whatever, is this new thread isrelated to this one https://www.mapleprimes.com/questions/237066-Determinant-The-System-Hangs, you would better keep this discussion goin in this latter thread.

@mz6687 

 

restart

with(LinearAlgebra):

with(plots):

with(Physics):

``

Physics:-Setup(mathematicalnotation = true);

[mathematicalnotation = true]

(1)

assume(x::real);

alias(v = v(x, t));

v

(2)

``

B1 := Matrix([[Physics:-`*`(Physics:-`^`(lambda__1-conjugate(lambda__1), -1), exp(Physics:-`*`(I, v__11))), 0, 0, 0, Physics:-`*`(Physics:-`^`(lambda__2-conjugate(lambda__1), -1), exp(Physics:-`*`(I, v__12))), 0, 0, 0], [0, Physics:-`*`(Physics:-`^`(lambda__1-conjugate(lambda__1), -1), exp(Physics:-`*`(I, v__11))), 0, 0, 0, Physics:-`*`(Physics:-`^`(lambda__2-conjugate(lambda__1), -1), exp(Physics:-`*`(I, v__12))), 0, 0], [0, 0, Physics:-`*`(Physics:-`^`(lambda__1-conjugate(lambda__1), -1), exp(-Physics:-`*`(I, v__11))), 0, 0, 0, Physics:-`*`(Physics:-`^`(lambda__2-conjugate(lambda__1), -1), exp(-Physics:-`*`(I, v__12))), 0], [0, 0, 0, Physics:-`*`(Physics:-`^`(lambda__1-conjugate(lambda__1), -1), exp(-Physics:-`*`(I, v__11))), 0, 0, 0, Physics:-`*`(Physics:-`^`(lambda__2-conjugate(lambda__1), -1), exp(-Physics:-`*`(I, v__12)))], [Physics:-`*`(Physics:-`^`(lambda__1-conjugate(lambda__2), -1), exp(Physics:-`*`(I, v__21))), 0, 0, 0, Physics:-`*`(Physics:-`^`(lambda__2-conjugate(lambda__2), -1), exp(Physics:-`*`(I, v__22))), 0, 0, 0], [0, Physics:-`*`(Physics:-`^`(lambda__1-conjugate(lambda__2), -1), exp(Physics:-`*`(I, v__21))), 0, 0, 0, Physics:-`*`(Physics:-`^`(lambda__2-conjugate(lambda__2), -1), exp(Physics:-`*`(I, v__22))), 0, 0], [0, 0, Physics:-`*`(Physics:-`^`(lambda__1-conjugate(lambda__2), -1), exp(-Physics:-`*`(I, v__21))), 0, 0, 0, Physics:-`*`(Physics:-`^`(lambda__2-conjugate(lambda__2), -1), exp(-Physics:-`*`(I, v__22))), 0], [0, 0, 0, Physics:-`*`(Physics:-`^`(lambda__1-conjugate(lambda__2), -1), exp(-Physics:-`*`(I, v__21))), 0, 0, 0, Physics:-`*`(Physics:-`^`(lambda__2-conjugate(lambda__2), -1), exp(-Physics:-`*`(I, v__22)))]]):

NULL

NULL

para_0 := [H__14 =0.3, H__33 = 1.5, H__38 = 0.15, H__44 = 1.5];
print():
para_1 := remove((x -> is(x in lhs~(para_0))), [entries(H, nolist)]) =~ 0;
print():
para := [para_0[], para_1[], c__1 = 0.5, nu = 1, alpha__1 = 1.5, alpha__2 = 1, lambda__1 = 0.58*I, lambda__2 = 0.68*I]

[H__14 = .3, H__33 = 1.5, H__38 = .15, H__44 = 1.5]

 

 

[H__11 = 0, H__12 = 0, H__13 = 0, H__15 = 0, H__16 = 0, H__17 = 0, H__18 = 0, H__12 = 0, H__11 = 0, H__13 = 0, H__16 = 0, H__15 = 0, H__18 = 0, H__17 = 0, H__13 = 0, H__34 = 0, H__17 = 0, H__18 = 0, H__55 = 0, H__13 = 0, H__34 = 0, H__18 = 0, H__17 = 0, H__55 = 0, H__15 = 0, H__16 = 0, H__17 = 0, H__18 = 0, H__11 = 0, H__12 = 0, H__13 = 0, H__16 = 0, H__15 = 0, H__18 = 0, H__17 = 0, H__12 = 0, H__11 = 0, H__13 = 0, H__17 = 0, H__18 = 0, H__55 = 0, H__13 = 0, H__34 = 0, H__18 = 0, H__17 = 0, H__55 = 0, H__13 = 0, H__34 = 0]

 

 

[H__14 = .3, H__33 = 1.5, H__38 = .15, H__44 = 1.5, H__11 = 0, H__12 = 0, H__13 = 0, H__15 = 0, H__16 = 0, H__17 = 0, H__18 = 0, H__12 = 0, H__11 = 0, H__13 = 0, H__16 = 0, H__15 = 0, H__18 = 0, H__17 = 0, H__13 = 0, H__34 = 0, H__17 = 0, H__18 = 0, H__55 = 0, H__13 = 0, H__34 = 0, H__18 = 0, H__17 = 0, H__55 = 0, H__15 = 0, H__16 = 0, H__17 = 0, H__18 = 0, H__11 = 0, H__12 = 0, H__13 = 0, H__16 = 0, H__15 = 0, H__18 = 0, H__17 = 0, H__12 = 0, H__11 = 0, H__13 = 0, H__17 = 0, H__18 = 0, H__55 = 0, H__13 = 0, H__34 = 0, H__18 = 0, H__17 = 0, H__55 = 0, H__13 = 0, H__34 = 0, c__1 = .5, nu = 1, alpha__1 = 1.5, alpha__2 = 1, lambda__1 = .58*I, lambda__2 = .68*I]

(3)

B1_para    := eval(B1, para);
detB1_para := Determinant(B1_para)

B1_para := Matrix(8, 8, {(1, 1) = -(.8620689655*I)*exp(I*v__11), (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = -(.7936507937*I)*exp(I*v__12), (1, 6) = 0, (1, 7) = 0, (1, 8) = 0, (2, 1) = 0, (2, 2) = -(.8620689655*I)*exp(I*v__11), (2, 3) = 0, (2, 4) = 0, (2, 5) = 0, (2, 6) = -(.7936507937*I)*exp(I*v__12), (2, 7) = 0, (2, 8) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = -(.8620689655*I)*exp(-I*v__11), (3, 4) = 0, (3, 5) = 0, (3, 6) = 0, (3, 7) = -(.7936507937*I)*exp(-I*v__12), (3, 8) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = -(.8620689655*I)*exp(-I*v__11), (4, 5) = 0, (4, 6) = 0, (4, 7) = 0, (4, 8) = -(.7936507937*I)*exp(-I*v__12), (5, 1) = -(.7936507937*I)*exp(I*v__21), (5, 2) = 0, (5, 3) = 0, (5, 4) = 0, (5, 5) = -(.7352941176*I)*exp(I*v__22), (5, 6) = 0, (5, 7) = 0, (5, 8) = 0, (6, 1) = 0, (6, 2) = -(.7936507937*I)*exp(I*v__21), (6, 3) = 0, (6, 4) = 0, (6, 5) = 0, (6, 6) = -(.7352941176*I)*exp(I*v__22), (6, 7) = 0, (6, 8) = 0, (7, 1) = 0, (7, 2) = 0, (7, 3) = -(.7936507937*I)*exp(-I*v__21), (7, 4) = 0, (7, 5) = 0, (7, 6) = 0, (7, 7) = -(.7352941176*I)*exp(-I*v__22), (7, 8) = 0, (8, 1) = 0, (8, 2) = 0, (8, 3) = 0, (8, 4) = -(.7936507937*I)*exp(-I*v__21), (8, 5) = 0, (8, 6) = 0, (8, 7) = 0, (8, 8) = -(.7352941176*I)*exp(-I*v__22)})

 

.1614404685*(exp(I*v__11))^2*(exp(-I*v__11))^2*(exp(I*v__22))^2*(exp(-I*v__22))^2-.3208471697*(exp(I*v__11))^2*exp(-I*v__11)*exp(-I*v__21)*(exp(I*v__22))^2*exp(-I*v__12)*exp(-I*v__22)+.1594131063*(exp(I*v__11))^2*(exp(-I*v__21))^2*(exp(I*v__22))^2*(exp(-I*v__12))^2-.3208471697*exp(I*v__11)*exp(I*v__21)*(exp(-I*v__11))^2*exp(I*v__22)*exp(I*v__12)*(exp(-I*v__22))^2+.6376524251*exp(I*v__11)*exp(I*v__21)*exp(-I*v__11)*exp(-I*v__21)*exp(I*v__22)*exp(I*v__12)*exp(-I*v__12)*exp(-I*v__22)-.3168179849*exp(I*v__11)*exp(I*v__21)*(exp(-I*v__21))^2*exp(I*v__22)*exp(I*v__12)*(exp(-I*v__12))^2+.1594131063*(exp(I*v__21))^2*(exp(-I*v__11))^2*(exp(I*v__12))^2*(exp(-I*v__22))^2-.3168179850*(exp(I*v__21))^2*exp(-I*v__11)*exp(-I*v__21)*(exp(I*v__12))^2*exp(-I*v__12)*exp(-I*v__22)+.1574112034*(exp(I*v__21))^2*(exp(-I*v__21))^2*(exp(I*v__12))^2*(exp(-I*v__12))^2

(4)

H_para := eval(H, para):

# Given that

B_para := 'H_para . B1_para';

# one gets:

detH_para := Determinant(H_para);
detB_para := detB1_para . detH_para:

Physics:-`.`(H_para, B1_para)

 

HFloat(6.560999999999999e-5)

(5)

# One possible simplification

whynot := simplify(combine(detB_para, exp)) assuming real;
whynot := convert(whynot, trig)

HFloat(2.0918187808685997e-5)*cos(2*v__11-2*v__12-2*v__21+2*v__22)+HFloat(6.275623380416999e-5)-HFloat(4.1837210793305994e-5)*exp(I*(v__11-v__12-v__21+v__22))-HFloat(4.1837210799866996e-5)*exp(-I*(v__11-v__12-v__21+v__22))

 

HFloat(2.0918187808685997e-5)*cos(2*v__11-2*v__12-2*v__21+2*v__22)+HFloat(6.275623380416999e-5)-HFloat(8.3674421593173e-5)*cos(v__11-v__12-v__21+v__22)+(HFloat(6.561002012950984e-15)*I)*sin(v__11-v__12-v__21+v__22)

(6)

 

NULL

 

Download Are_you_ok_with_that.mw

 

@mz6687 

Sorry, I don't understand what you say



@mz6687 


Your initial question was "Can Maple solve the determinant of the 9x9 matrix? "
I showed you the answer was YES.

Now you are talking about something else.
But you missed a point: in the reference you mention the matrix had a particular shape and depended only on 6 quantities

{v__11, v__12, v__21, v__22, lambda__1, lambda__2}

So the expression of its determinant was potentially simplifiable (and indeed was).

Your matrix B is dense and depends on 81 indeterminates (not only 6) meaning  there is no possible simplification between terms.
Using simplify or collect, for instance, will be a dead end.

Things could be completely different if all the m[i, j] were expressions involving a few number of independent quantities.


BTW: what does "solve the determinant" mean to you?

@acer 

You're right, I edited my answer consequently.

@Traruh Synred 

I know how to use Histogram, but I want to plot binned data!

Can you please give an example of those binned data and of the original data instead of speaking in the void?

For one thing, a Histogram requires a large list of each data point and is thus a memory hog, and each time you make a histogram Histogram loops through the data for the quantity, and if you make it for a related quantity you have to loop again. 

That is totally unclear, can you provide an example?

@AHSAN 

Your claim that "each curve have their maximum point at some vale of x" is obviously wrong (last figure on my last file on forst figure in For_reference.mw ... soom around the peaks).
and not consistent with your need "to obsrvse that difference in percentage at the maximum value of x
" at the same time (if x is a constant as you before claimed it was it' difference in percentage is 0).

I hope you'll find someone better able than me to understand the subtleties of your question.
For my part, I'm done with you.

@AHSAN 


I still don't understand what is your criterion to assess this relative increase/decrease:

  • Is this criterion the height of the peak?
     
  • You taught before of "enlargement"; is your criterion the peak width at some conventional height?
     
  • Is this criterion one of those I use in my first file?
     

Whatever, the case here is an example based on the peak height
Could_It_Be_This_2.mw

@AHSAN 

My mistake, this phrase about "a loop" is indeed an error.

It's likely  I didn't understand correctelyyour question.
I understood you wanted to compite the decrease/increase of the eights of the peaks.

What do you mean by "the decrease or incease in percentage between curves" ?
If you this

A_ref := eval(A, lambda = 1.3015):
data_1 := [beta=0.1, Q=1.3015, lambda=0.9986];
B_1    := eval(B, data_1):
plot((B_1-A_ref)/A_ref*100, x=-4..0)

you get a curve which represents the relative variation of B_1 wrt A_ref, but this is a function x.
So do you want a number or an algebraic expression or a curve

Could_It_Be_This.mw

@dharr 

Right, I didn't pay attention to that.

First 7 8 9 10 11 12 13 Last Page 9 of 28