Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Recently I came back on the general problem of drawing the syntactic graph of a mathematical expression.
Probably some of you have already done this as students for it is a classic when you learn recursive procedures, chained lists or graphs.

I wasn't interested in doing this with Maple, because Maple had already done  a part of the job thanks to the procedure ToInert.
More of this, the package GraphTheory seemed to possess all the required features to obtain quickly this syntactic graph.
Nevertheless it took me a lot of time to fix (almost all) the problems.
The issues are mainly of two orders:

  1. ToInert is very verbose: a necessary feature when you want to have a non ambiguous syntax of an expression, but partly useless for simple visualization.
    Here is an example
    ToInert(f(x))
    _Inert_FUNCTION(_Inert_NAME("f"), _Inert_EXPSEQ(_Inert_NAME("x")))

     

  2. GraphTheory 
    Once the inert form of the expression is known, it is necessary to put it in a form that can be manipulated by the procedures of the GraphTheory package.
    More precisely one needs to transform this inert form into a set of lists [a, b], where a and b are two neighboring vertices of the syntactic graph and [a, b] the directed arc from a to b.
    As the syntactic graph is a tree, this implies using edges {a, b} instead of arcs [a, b].
    The problem is that some operators are commutative while others are not: for the latter this means that the edges and vertices on the syntactic graph must appear in an order that respects the non-commutativity.
    Here his a toy example where I manually buid the syntactic graphs of a/b and b/a: the two graphs are identical and this comes from the fact that edges in Graph( edges )  must be a set, thus an ordered structure whose order doesn't care about non-commutativity.

    restart:
    with(GraphTheory):
    # The first is aimed to represent the expression a/b
    # while the second is aimed to represent the expression b/a
    Gdiv := Graph({{"/", "a"}, {"/", "b"}}):
    g1 := DrawGraph(Gdiv, style=tree, root="/", title=a/b):
    
    Gdiv := Graph({{"/", "b"}, {"/", "a"}}):
    g2 :=DrawGraph(Gdiv, style=tree, root="/", title=b/a):
    
    plots:-display(<g1 | g2>)
    

    Download ab_ba.mw

     

After several attempts, I decided to discard the GraphTheory package, that is to deprive myself of all the interesting features one needs to manipulate a graph.

The result is given on the attached file (... and the content of the worksheet can't be loaded as usual).

Download Syntactic_Graph.mw

Here is an example


Twelve test cases are given, all the corresponding syntactic graphs are correct, but one of them (test case iexpr=1) seems incorrect because the right child of a parent P is located to the right of the left child of a parent P', even though P' is to the right of P.
This could be corrected by modifying the way the posiitons are computed in procedure Place.


PS : It doesn't seem that Maple has a built-in procedure to construct the syntactic graph of a mathematical expression.
But maybe I'm wrong?


 

 

Hi, 
I wonder what is I in MAPLE?
Obviously I is not an indeterminate

z := a+I*b:
indets(z);

# but

has(z, I)
                             {a, b}
                              true

What does this answer mean:

whattype(I);
                   complex(extended_numeric)

I would have thought that  I was some kind of protected symbol such as Pi, but it's not

attributes(Pi);
attributes(I);
                           protected

In fact, trying to assign 1 to I just returns an error saying this is not legal assignment

I:=1
Error, illegal use of an object as a name

So, what is I in Maple?

Thanks in advance

Dear all,

I have a long Maple code.

After running the code, suppose that we get an error in one of the lines.  I can't simply find the mouse cursor in the line which includes the error.

Question 1: How to find quickly which line has the error? What are your solution methods?

Question 2: Enlarging more or highlighting the cursor mark maybe works. Is it possible?

When i trying to solve the BVP the following error will found 

Error, (in fproc) unable to store 'HFloat(1.0141653815612295)+HFloat(0.0020355870386861838)*I' when datatype=float[8]
 

I have attached my worksheet.

Please anyone help me to get solution to this problem.

Thank you so much

Download Main.mw

 

Hello Maple friends,

I use Explore() often and noticed something today which seems like either a bug or an error on my usage.

I have a long worksheet where I use Explore at one point to show the behavior of an expression relative to one parameter assigned to a slider. Later in the sheet however, I re-assign some of the variables used in that expression and I call Explore again to see how the expression behaves with the different parameters.

The issue is that when I move the slider on the first explore, the result is incorrect because it seems to be using the values of the variables at the end of the worksheet, not the variables at the point the Explore statement exists.

I would expect Explore to make a copy of the stack at the point it gets called such that the result is correct in the context of its location in the worksheet.

Is this the correct behavior and is there a way to make this work as expected? The only workaround I have in mind is to rename the variable names just to make Explore work, which doesn't seem like a great solution.

Thanks.

blessing.mw please i really need your help on this, i have been trying to fix this error for a while now. 

I have function that accept keyword argument. From this function, I need to pass this argument to another function using the same signature and using same name for the keyword. But it is not possible to do. 

Easier to explain with an example.   This is what I want to do

restart;
foo:=proc(n::integer,{ic::`=`:=[]})   
   post_process(n+1,'ic'=ic);
end proc;

post_process:=proc(n::integer,{ic::`=`:= []})
    print("in postprocess, n=",n, "ic=",ic);
end proc;

foo(3,'ic'=(y(0)=5))

Gives 

The problem is that when calling post_process(), using 'ic'=ic it does not work. Currently I have to change the keyword name as workaround, like this

restart;
foo:=proc(A::integer,{ic::`=`:=[]})
   print("in foo, A=",A, "ic=",ic);
   post_process(A,'new_ic'=ic);
end proc;

post_process:=proc(A::integer,{new_ic::`=`:= []})
    print("in postprocess, A=",A, "ic=",new_ic);
end proc;

foo(3,'ic'=(y(0)=5))

Which gives

Now it passed it. I would have liked to keep same keyword name ic in both function signatures instead of coming up with new name.

Is there a way to do that? 

This is not the only problem. The problem with this workaround, is that it does not work when the keyword argument is not passed to the first function. Because now it will use the default values of [].

Hence when calling the post_process() function, it fails due to type mismatch. This now gives an error

restart;
foo:=proc(A::integer,{ic::`=`:=[]})
   print("in foo, A=",A, "ic=",ic);
   post_process(A,'new_ic'=ic);
end proc;

post_process:=proc(A::integer,{new_ic::`=`:= []})
    print("in postprocess, A=",A, "ic=",new_ic);
end proc;

foo(3)

 

Error, (in foo) invalid input: post_process expects value for keyword parameter new_ic to be of type `=`, but received []

So the way I do this now, is to add an extra check each time, like this

restart;
foo:=proc(A::integer,{ic::`=`:=[]})
   if nargs = 2 then #is ic passed in?     
      post_process(A,'new_ic'=ic);
   else
      post_process(A);
   fi;
end proc;

post_process:=proc(A::integer,{new_ic::`=`:= []})
    print("in postprocess, A=",A, "ic=",new_ic);
end proc;

foo(3)# now it works

But in my actual code, I have more than one keyword argument, and I have to keep checking for correct number of arguments each time, to know which arggument to pass along. 

So far, I did not find an easy way around this.

Any suggestion how to do this better? passing keyword argument with default values? from one function to another without getting into these problems?

Maple 2020.2

 

Dear All 

I would like to calculate the five first terms of a  polynomial  sequence

I wrote in maple 

sum(x^r*(sum((-1)^s*binomial(r, s)*pochhammer((a+s+1)*d, n), s = 0 .. r))/factorial(r), r = 0 .. n), n = 0 .. 4);

I obtained 

0,0,0,0,0

which seems to be false

where is the problem 

Best regards 

This simple set of integrations works correctly and quickly in Maple 17 and other releases, but not in Maple 2020.

psi(x) := (-1)^v*(alpha*GAMMA(k-v)/v!/GAMMA(k-2*v-1)/GAMMA(k-2*v))^(1/2)*exp(-1/2*k*exp(-alpha*x))*                 (k*exp(-alpha*x))^(1/2*k-v-1/2)*LaguerreL(v,k-2*v-1,k/exp(alpha*x))/binomial(k-v-1,v);

Int(eval(%, [k=30.5, v=j, alpha=2.5])^2, x=-1..infinity) =
   seq(evalf[12](Int(eval(%, [k=30.5, v=j, alpha=2.5])^2, x=-1..infinity)), j=0..5);

Every time that I try this simple integration in Maple 2020 I receive a message "kernel connection lost".  Why???

Hi there,

what's wrong with this example:

ph_ex.mw

?

Thank you

Dear all

I have  Lie commutations for vectors e1, e2, e3, e4, e5, e6 as follow:

[e1, e3] = e3, [e1, e4] = e4, [e1, e5] = e5, [e1, e6] = e6, [e2, e3] = -e5, [e2, e4] = e6, [e3, e5] = e6

for which the command 

Query("Jacobi")

returns the false result, which means, the vectors are not closed under Jacobi's identity. How can I find vector triplets for which Jacobi's identity does not hold?

Please find Maple file.Jacobi_identity.mw

Hey everyone!
I have to solve this nonlinear system of equations . For small N (N=8), I tried to do it using solve but it is run forever. I have choosed \gamma to be equal to Pi/4.
test.mw

I tried to expand by the procedures series() and taylor(), but they compute to O(x15).

Hi

I have two sets of plots

1. plot([1 - 2*x, -0.6 - 2*x, -1 - 2*x], x = -1 .. 1)

2. smartplot[x, y](map('`=`', [31*y^2 + 0.19*x^2 + 0.34*x*y - 0.38*y - 0.22*x + 0.07, 0.31*y^2 + 0.19*x^2 + 0.34*x*y - 0.38*y - 0.22*x, 0.31*y^2 + 0.19*x^2 + 0.34*x*y - 0.38*y - 0.22*x + 0.02, 0.31*y^2 + 0.19*x^2 + 0.34*x*y - 0.38*y - 0.22*x + 0.07, 0.31*y^2 + 0.19*x^2 + 0.34*x*y - 0.38*y - 0.22*x + 0.11], 0))

How do i combine the two into one plot?

thanks!

R

 

Why Maple gives this error and is this a known issue?

restart;
pdsolve( [diff(u(x,t),t)=diff(u(x,t),x)*diff(u(x,t),x$2), u(x,0)=0],u(x,t))

Maple 2020.2 with Physics 893 on windows 10.

 

First 463 464 465 466 467 468 469 Last Page 465 of 2223