Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

What is a good way to determine, at run time, a free symbol to use inside a proce, so it does not appear the same as one being passed in from outside?

Here is the problem. Inside a proc, user calls it with an ODE. The independent variable is passed in as the argument called x

Inside this proc, it does change of variables to do something else.  If the proc uses say as the new variabe, this could be the same as the passed in argument in the way it appears when being printed out to file.  

I know the local symbol is not the same as the passed in symbol, even if that happend to be also. As one is local and the other is not. So the math will still work, but the display will look very confusing to the user.

But since I am printing these out, these will show the same. 

So I need a way to make symbol inside proc, which looks different from the one being passed in.

An example will show the problem. 

foo:=proc(ode::`=`,y,x)
local t; #hoping this will not be the same looking as actual x
return PDEtools:-dchange({x=t^2},ode,t)  
end proc;

Now it is called as

ode:=diff(y(x),x)=sin(x);
foo(ode,y,x)

Which gives

The above worked, because the independent variable being passed in happend to be x

But if the proc was next called using global as the independent variable

ode:=diff(y(t),t)=sin(t);
foo(ode,y,t)

The output will be the same. Which looks confusing.

I want the out in this case to be using different letter than t, say z

The point is, the proc needs to use different looking symbol. Since it does not know which symbol the user is using, currently I use Z  since this is not likely to be used as independent variable by a user. most odes use x or t or z as independent variables

Again, this is all for display purposes, as I am printing these out, and want to avoid using the same looking symbol.

What is a good way to come up with symbol that does not look like the one being passed in?   The option of the user passing in the extra variable to use for this is not possible at all, as this is done deep inside and asking the user to pass in the spare symbol to use is not possible.

 

 

Hi all, I have a question and hope to get answered.

Let

f := x + 1 = (x^2 - 1)/(x - 1);

Maple command `is(f) = true` but `evalb(f) = false`. So which case should be use `is()`, which case should be use `evalb()`? 

I think, `evalb` is used to compare numbers and `is` used to compare expression, logic. Is this true?

Thank you very much.

Hello

Although I have read the help file on how to use try-catch commands, I am not sure how they work exactly.  Here is an example of how I used them. (It is just a pseudocode).

myrout:=proc(arg1,arg2,arg3,args4,arg5)
try 
   .....
   timelimit(...)
   if condition then 
      ....
   else 
      timelimit(...)
      .....
   end if:
catch "time expired":
    return([a,b,c,d]):
finally
    .......
end try:
return([res1,res2]):
end proc:

Questions:

1) Does catch catch "time expired" from both calls of timelimit?  

2) Will the set of sequences under finally be executed when a "time expired" is caught? Somehow reading the help file i had the impression that it will.  If that is the case, how can it be avoided?  

 

Many thanks

Ed

I have a surface given by all the points that fulfil:

(y-1)^2+z^2=1, x=1, z>=0

How can I plot this surface in Maple?

Even though I was using the thoughtful answer provided by a poster in a previous MaplePrimes question, I was unable to successfully place labels on a column graph.  I have reduced the problem to adding a plots:-setoptions call, of any type, before calling ColumnGraph:
 

restart

with(Statistics)

T := [StringTools[CharacterFrequencies]("antidisestablishmentarianism")]

["a" = 4, "b" = 1, "d" = 1, "e" = 2, "h" = 1, "i" = 5, "l" = 1, "m" = 2, "n" = 3, "r" = 1, "s" = 4, "t" = 3]

(1)

ColumnGraph(T)

 

plots:-setoptions(size = [300, 250])

ColumnGraph(T)

Error, (in Statistics:-ColumnGraph) expecting plot structure but received: ROOT(BOUNDS_X(0), BOUNDS_Y(0), BOUNDS_WIDTH(300), BOUNDS_HEIGHT(250))

 

 


 

Download ColumnGraph_Problem.mw

 

The challenge for me is that for my work, several default plot parameters require changing including the default plot size which is too large. Hence my Maple initialization file includes calls to plots:-setoptions. Is this a bug in the ColumnGraph command and is there a work around that does not include removing the plots:-setoptions from my initialization file? Note: this problem occurs both in Maple 2019 and 2020. 

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 :)

First 510 511 512 513 514 515 516 Last Page 512 of 2217