MaplePrimes Questions

Hello,

I have noticed a small decrease in real time running 4 cpus versus 1 cpu. I am not sure if implemented the multi-threads  feature correctly or efficiently. Could you please show me some alternative coding methods with even more improvements? Thanks in advance.  

 

# Generative Model

n_trials := 16:
n_sample := 1:

subscribers := Vector[row](n_draw):
gen_model := proc(ib,ie)
        global n_trials, n_sample, prior_rate;
        local i, Y;
        for i from ib to ie do
          Y := RandomVariable(Binomial(n_trials, prior_rate(i)));
          subscribers(i) := apply(Sample(Y, n_sample), 1):
        end do:
        return subscribers:
end proc:

# Multi-threads, use 4 cpus
gm1 := Create(gen_model(1, n_draw/4), out1):
gm2 := Create(gen_model(n_draw/4 + 1, n_draw/2), out2):
gm3 := Create(gen_model(n_draw/2 + 1, 3*n_draw/4), out3):
gm4 := Create(gen_model(3*n_draw/4 + 1, n_draw), out4):


Usage(Wait(gm1, gm2, gm3, gm4));
memory used=1.97GiB, alloc change=0.52GiB, cpu time=83.56s, real time=45.52s, gc time=6.20s

 

ApproxBayesComp_Threads_2.mw

I have a position vector in 3D space of  <t,0,(2/3)t^(3/2)>,0<=t<=8. I found the unit tangent vector to be <1/((1+t)^(1/2)),0,(t^1/2)/((1+t)^(1/2))>. I am not sure how to graph the unit tangent vector and the position vector together. I attached the file I am working in.

 

Unit_Vector_Tangent.mwUnit_Vector_Tangent.mw

Dear friends

I need to solve this integral analytically. But I don't know how to do it. Could you please help me?

This does not work:

p := sqrt(2/(3*A*L*ln(t)^(L-1)+3*a*t));
int(p, t);

Here, "A" and "a" are positive constants, "L>1" and also I need the solution for "t>1"

Thanks

 

Dear All,
Before anything, I have to convey that this question has been already asked by me; however, I don't know why my question has been deleted by MaplePrimes!!!
It is necessary to mention that two persons replied to my question which I can't see them, unfortunately. Nevertheless, if it is possible, please send me your reply to Hassani@nit.ac.ir.
Now, My question is as follows.
I could apply ‘map’ command to execute ‘taylor’ command of sine function as the following:
map(taylor, [sin(x)],x=0,10);
The above is equivalent to the below:
taylor(sin(x),x=0,10);
However, I can’t apply “Grid:-Map” command to derive Taylor series of the sine function. The below command returns an error.
Grid:-Map(taylor,[sin(x)],x=0,10);
Can anyone tell me the reason of?
Best wishes,

Hi,

I'm just trying Maple 2020.

In Maple 2016, a package may be loaded at restart by creating the file: 

c:\Program Files\Maple 2016\Users\maple.ini

and writing in it:

libname:= "F:\\Maple\\Trilinears", libname: 
currentdir("F:\\Maple\\Trilinears"):
libname:= "F:\\Maple\\mysql", libname:

 

But this does not work in Maple 2020.

What is the workaround for loading these packages when restart is executed?

Thanks in advance,

César Lozada

 

 

 

ApproxBayesComp_for_loop.mw

The observed data were 6 out 16 people signed up. Priors were defined by a uniform distribution. A Generative Model utilized a binomial distribution. A distribution of subscribers were generated, see plot below. By filtering the subscribers distribution for the value is equal 6, the posterior distribution was obtained. Why is the frequency the highest for subscribers = 16? Where did I go wrong in coding this problem?

how to draw and calculate the angle of a dihedral of a regular tetrahedron ? Thank you.

Dear maple users,

Greetings.

When converting the maple figure into EPS format (for latex) which shows white patches.

How to avoid such patches.

Hi

This Carl Code evaluates fine

MySumP:= (j::integer)->
    seq(combinat:-numbcomb((j+10),(i+10))*p^(j+i)*(1-p)^(j+i), i= 0..0);
:[MySumP(10)]


[184756*p^10*(1 - p)^10]

But what I would like is whats inside the numbcomb argument to be displayed.

i tried

MySumP:= (j::integer)->
    seq(combinat:-numbcomb(``(j+10),``(i+10))*p^(j+i)*(1-p)^(j+i), i= 0..0)
:

[MySumP(10)]

What i would like displayed: numbbomb(20,10)*p^10*(1-p)^10 or (better) C(20,10)*p^10*(1-p)^10

Hi,

Is there any way we could use Maple to simplify an equation,

Example: M= 2pqrst / uvw 

I would like a code or a way to separate some variables into one variable, where the expression would be M = 2Krst / w

which can be said that K = pq / uv

I know that I can use the simplify command but it's only worked for simpler expression but not complicated one.

Really need help from you guys. 

 

Thank you :)

How can I define and solve an ordinary differential equation with a random input (random inhomogeneous part)?

d2X(t)+c*dX(t)+k*X(t)=F(t)

where f(t) is a random function with normal distribution.


I tried to simplify it, but It didn't work that well.

simplify(%)

 

I always feel that this formula can be further simplified, but there is no way to start. Of course, My thoughts maybe incorrect. maybe this is the simplest form.

 

 

 

 

 

 

For last 4 hrs, I've been chasing this problem.

Inside a module, there is a proc with a name say foo().

It is local to the module. When creating an .mla file that contains this module which was read from .mpl file, and running a test against it, Maple does not see this specific proc foo() as a proc, but only sees it as a symbol.

So the call to foo() never happens (error is generated).

I have a print statement inside foo() also which never prints. In the debugger, when I try to step into foo(), it fails also. Maple simply does not see it as a proc.

I also added my_module:-foo() in call, but this made no difference, even though it is not needed to prefix the module name, since foo is a local proc.

Now, instead of making an .mla, I now just read the .mpl file directly which make up the module. And now run the same test, and now maple see foo() as proc and the test runs with no error.

No change in the code at all. Nothing changed, exacept the test is called one time when package is inside the .mla vs. just using plain .mpl files.  The module has option package on it.

It seems something goes wrong with symbol table when inside mla file.

When I do 

libname := currentdir(), libname;
LibraryTools:-Browse()

And browse the content inside my mla file, I see no problems, it lists all 24 procs inside the package, and I can see foo listed there as type PROC.

But in the code, what printing whattype(foo)  it says it is symbol when using mla file, but it says it is a procedure when not using mla, but just by reading the .mpl file which went into the .mla

I will try to make an example to reproduce this if I can. But has any one seen something like this before? What could cause this?  I've restarted Maple ofcourse, and this made no difference.

The way I build the mla is

FileTools:-Remove(cat(currentdir(),"/my.mla"));
LibraryTools:-Create(cat(currentdir(),"/my.mla"));

read cat(currentdir(),"/my_module.mpl");
LibraryTools:-Save('my_module',"my.mla");

For now, I will stop using .mla and just read the .mpl file each time to use the code, as this seems safer and this always worked and never gave any problems.

The code is large. I also use database. So I am not sure I can make a small example but will try.  

I am using 2020.1 on windows 10.

I am not able to use Maple's map() to do the following. Given 2 lists of things (of equal length), map a function that take 2 arguments, from these 2 lists, in order.  Here is an example to illustrate. In Mathematica

a = {1, 2, 3}; b = {7, 8, 9};
MapThread[f, {a, b}]

           {f[1, 7], f[2, 8], f[3, 9]}

In Maple, I tried map and map2, map[n] etc.. not able to get the result I want. I want to use map, and not ~

A:=[1,2,3];
B:=[7,8,9];
map((x,y)->f(x,y),A,B)

          [f(1, [7, 8, 9]), f(2, [7, 8, 9]), f(3, [7, 8, 9])]

 

map[2]((x,y)->f(x,y),A,B)

           [f([1, 2, 3], 7), f([1, 2, 3], 8), f([1, 2, 3], 9)]

and other things.

How to get same result as MapThread, using map?

In your answer, please include the calculation of the lamina's area and the location of its centre of mass.

Lamina.mw

First 516 517 518 519 520 521 522 Last Page 518 of 2427