Maple 2020 Questions and Posts

These are Posts and Questions associated with the product, Maple 2020

Does Maple have any faciltiy to find any solution to two equations in  3 variables subject to constraint that each equation is not zero?

Here is an example. I like to find any values of t1,t2,t3 such that alpha and beta are not zero. Any choice of such t's will do. But not all can be zero ofcourse. All the t's are linear.

restart;
eq1:= alpha = -2*t1 - 4*t2 - 2*t3;
eq2:= beta = t1 + 2*t2 + t3;

By inspection we see that choice t2=0,t3=0,t1=1 works since

subs([t2=0,t3=0,t1=1],[eq1,eq2])

There are many other choices (infinite). I just need to find one combination of t_i in the integers.

I could write a loop and keep trying different values of t1,t2,t3 until I find such choise ofcourse. But I was wondering if there is better way to do this in Maple. Solve does not work on this ofcourse.

solve([eq1,eq2,eq3],[t1,t2,t3]) assuming alpha<>0,beta<>0

And setting up Ax=b does not work

restart;
A:=Matrix([[-2,-4,-2],[1,2,1]]);
b:=Vector([alpha,beta]);
LinearAlgebra:-LinearSolve(A,b)

Error, (in LinearAlgebra:-LinearSolve) inconsistent system
 

However, one thing I could do, is pick random alpha,beta values, and then solve for t_i, as in

restart;
A:=Matrix([[-2,-4,-2],[1,2,1]]);
b:=Vector([-2,1]);
LinearAlgebra:-LinearSolve(A,b)

And now I am able to find a solution I want. The problem with this method, is that if I pick wrong values of alpha,beta, I can also get no solution. For example, if I guessed alpha=1,beta=1 I get

restart;
A:=Matrix([[-2,-4,-2],[1,2,1]]);
b:=Vector([1,1]);
LinearAlgebra:-LinearSolve(A,b)

Error, (in LinearAlgebra:-LinearSolve) inconsistent system
 

So one option I could try, is pick random values of alpha,beta, and call LinearSolve until I get a choice which works?  i.e. one which does not give inconsistent system.

Thanks for any better suggestions.

This is the context: I call LinearAlgebra:-LinearSolve to solve system of linear equations. If there are infinite solutions, then Maple return the solution that has free variables, calling them using  _t[n] where can change each time and be different. It can also be _t0[n] and _t1[n] etc.. but these all are indexed variables.

I want to obtain a list of all these free variables in the resulting solution vector, so that later I can assign them some values.

But I do not know what can be. And how many of them there are. There could be _t[3] and _t[4] for example in the same solution vector.

Here is what I do now, where I just check for indexed type. This seems to work, since only _t[n] should be in the resulting solution if any.

restart;
A:=Matrix([[0,1,-1],[-1,-2,2],[-1,-2,2]]):
v:=Vector([-1,1,1]):
sol := LinearAlgebra:-LinearSolve(A,v);

map(x->select(type,x,'indexed'),convert(sol,set))

I do not know how to tell it to look for all something that starts with  _t and also indexed type.

Is there a better way to obtain list of all _t[n] that LinearAlgebra:-LinearSolve could return? Will LinearAlgebra always return the free variables as indexed variables so I am sure the above will always work?  Do you see a problem with the above solution?

It is annoying that some functions in Maple wants input like (a,b,c,.....) which represents numbers, and I am not able to find how to use such a function, because the list of numbers I have are in a list.

For example, ilcm and igcd.  This is not a good design. The input should have been a list or set, or vector, etc.... 

I wanted to find least common multiplier of a list of numbers. These numbers are allready in a list, since this is a result of a computation done earlier. Now I want to find ilcm of them. 

How to use ilcm in this case? How to unpack them to make ilcm happy? In Mathematica there a special function to do this, called Sequence, which takes a list and unpack it to call function. 

But I am not able to find one in Maple. There is no convert(list,exprseq). 

Here is a MWE

v:=[2,4,7];
ilcm( v ); #does not work, since ilcm does not accept a list

The variable v above has to be in a list (or set, or vector). This is result from another computation. This is all done non-interactive. 

So I am looking for some magic function to use it like this

v:=[2,4,7];
ilcm( convert_to_expression_sequence(v) )

Is there a way to unpack or convert list to expression sequence, so I can use ilcm?

This is my attempt. But I suspect there is a build-in way in Maple to do this which I have not found yet.

restart;

convert_list_to_exprsequence:=proc(L::list)::exprseq;
local r:=NULL,item;

for item in L do
    r:=r,item;
od;

return r;
end proc:

v:=[2,4,7];
ilcm(convert_list_to_exprsequence(v)); #now it works

                  #28

Maple 2020.1

How I can find the coefficient an, and bn according to the following solution?

the coefficients an and bn can be found by solving the
two linear equations that come from V = V[0] at eta=eta[0] and 
V = V[1] at eta=eta[1], and comparing with following Eq in each
case.

Best

2.mw

 

 

 

 

I'm thinking of better demonstrating the cartesian product of a graph.
With the help documentation, we can easily find the cartesian product of two graphs.

with(GraphTheory):
G := CycleGraph([v__1,v__2,v__3,v__4]);
H:=Graph({{u__1,u__2}}):
DrawGraph(G,size=[250,250],stylesheet=[vertexborder=false,vertexpadding=10,edgecolor = "Red",
vertexcolor="navy",edgethickness=3]);
DrawGraph(H,size=[250,250],stylesheet=[vertexborder=false,vertexpadding=10,edgecolor = "Blue",
vertexcolor="Gold",edgethickness=3]);


GH:=CartesianProduct(G,H)
DrawGraph(GH,style=spring)

 

 

 

When I saw Wikipedia's demo diagram, https://en.wikipedia.org/wiki/Cartesian_product_of_graphs

I was fascinated,and I also wanted to visually reflect the nature of Cartesian product by doing different staining of vertices.
It is easy for me to dye the vertices in one color, but it is difficult for 
two different colors .

 

restart;

kernelopts(version);

`Maple 2020.1, X86 64 LINUX, Jul 30 2020, Build ID 1482634`

This one works as expected:

solve({x + y = 5, x - y = 3});

{x = 4, y = 1}

This one fails:

solve({x(0) + y(0) = 5, x(0) - y(0) = 3});

That shouldn't fail.  According to ?solve,details, under the Description

heading, it says that the unknown may be a name or a function.  Note that

type(x(0), function);

true

so there seems to be a contradiction.  Nevertheless, there is a workaround:

solve({x(0) + y(0) = 5, x(0) - y(0) = 3}, {x(0), y(0)});

{x(0) = 4, y(0) = 1}

 

Now try with fsolve().  This one works as expected:

fsolve({x + y = 5, x - y = 3});

{x = 4., y = 1.}

This one fails:

fsolve({x(0) + y(0) = 5, x(0) - y(0) = 3});

But the previous workaround does not help:

fsolve({x(0) + y(0) = 5, x(0) - y(0) = 3}, {x(0), y(0)});

I can temporarily rename the variables to plain symbols, or perhaps

freeze/thaw them.  But is there a simpler workaround?

 

 

Download fsolve-problem.mw

 

Maple's gamma constant appears to misbehave.

restart;

kernelopts(version);

`Maple 2020.1, X86 64 LINUX, Jul 30 2020, Build ID 1482634`

evalf(gamma);     # this one is expected

.5772156649

evalf(gamma(0));  # this one may be explained

.5772156649

evalf(gamma(1));  # how to explain this one?

-0.7281584548e-1

Things get more puzzling.  Let's declare gamma as local:

local gamma:

Warning, A new binding for the name `gamma` has been created. The global instance of this name is still accessible using the :- prefix, :-`gamma`.  See ?protect for details.

evalf(gamma);     # this is good

gamma

evalf(gamma(0));  # expected an unevaluated gamma(0) here!

.5772156649

evalf(gamma(1));  # expected an unevaluated gamma(1) here!

-0.7281584548e-1

 

Download gamma-puzzle.mw

 

Is there a way to prevent Maple from applying the product rule for exponents? That is, keep x*x as it is instead of automatically simplifying it to x^2. Or, alternatively, is there a way to decompose x^2 as x*x?

Hi there.

It seems like a bug in modp1(('Rem')(...)) with large polynomials with large coefficients.

Please look at the file:

bug_rem.mw

It needs the file polys.m there:

https://dropmefiles.com/9fATR

File polys.m too big for this forum so I used dropmefiles.

Polys.m contain two polynomials x and f_t with large degrees: degree(f_t) = m = 50021, degree(x) = 2*m - 2 = 100040 and large coefficients up to 2^N, where N = ceil(m / 2)+2 = 25013.

I just compute rem(x,f_t) mod 2^N.

As you can see in the first part of doc bug_rem.mw I decreased coefficients of polynomials by additional mod 2^N (with Embed function), where N = floor(N / 2) = 12506. WIth these decreased polynomials and decreased N modp1(('Rem')(...)) function works well and use maximum about 2.5 Gb of RAM.

But in the second part of doc bug_rem.mw with original polynomials and N = 25013 modp1(('Rem')(...)) use maximum about 3.5 Gb of RAM and crash with error:

Error, Maple was unable to allocate enough memory to complete this computation.  Please see ?alloc
 

This is strange and looks like a bug considering that the test server has 48 Gb of RAM.

Is it a bug or modp1(('Rem')(...)) just need more than 48 Gb of RAM?

How many RAM it needs for this computation?

Thank you

Hello, I am trying to fix the problem reported below.

I am using the 64 bit version of Maple 2020.1. I am experiencing similar problems with other java applications. So I believe it must be something related to Java.

Moreover, it looks like the local refreshing problem is following the cursor of the mouse, therefore it must be something related to the interaction of the mouse with the GUI.

I am using a I7 CPU, 32 GB of Ram and a Nvidia Geforce RTX 2070.

Is anyone experiencing something like this? How can I fix this?

My personal edition of Maple 2020 throws java-lang-thread for every plot3d. No further output is provided by Maple. How can I further troubleshoot this?

Dave

For entering system of linear ode's, from textbook, such as this example

I can either use x[1],x[2]  or x__1 and x__2.

Maple dsolve works with both. The Latex generated is also exactly the same Which is x_{1} and x_{2}.

The only minor difference I see is on the screen in the worksheet (I only use 1D), where the subscript looks a little nicer in the case of x[1] vs. x__1

The subscript in the case of x[1] is upright while the one in x__1 is italic. I like the first one more.

Other than this cosmetic difference, Are there are subtle sematic differences between the two forms in terms of computation? I know x[1] create table x. OK.  While x__1 is a separate symbol. No table is created.,

Which would be  a safer/better option to use in this case?   Or is it just a matter of choice?

sys:=[ diff(x[1](t),t)=x[1](t)+x[2](t),diff(x[2](t),t)=x[1](t)+3*x[2](t)];
sys:=[ diff(x__1(t),t)=x__1(t)+x__2(t),diff(x__2(t),t)=x__1(t)+3*x__2(t)];

In some way, using x__1(t) might be a little easier to read on the eye than x[1](t) since there is only one type of paranthesis involved.

ps. I tried to search for __ in Maple help to read more about it, but ?__ do not show it. I am sure __ is in the help under some other name.

For display only purposes, to get the Latex looking better, I replace the constant of integrations Maple using which is _C1, _C2., etc... to c[1],c[2],..... 

This is something I do at the very end of computation, just before I get the Latex of the expression.

The way I do this now, is not good. .And I am asking if there is a better way to do this replacement. In Mathematica, I can do this using a patterm where I tell it to replace  C?  by c[?] where ? means anything.

Is it possible to do something like this in Maple? Here is an example

sol:=dsolve(diff(x(t),t$3) = x(t));

This gives solution as

And just before ask for the Latex of this, I change it to 

This is done using a function. Please see worksheet below.

The problem with the current solution is that I do not know how many _C there are, so I assumed 10 as worst case, which works for my case. But I prefer a more general solution, may be using pattern in the subs command?


 

restart;

replace_all_C:=proc(expr::anything)
local n,N,c;
local new_expr;
local max_count :=10; #worst case, since do not know how many

    new_expr:=expr;
    for n from 1 to max_count do
        N:=convert(n,string);
        new_expr:=subs( :-parse(cat("_C",N))=:-parse(cat("c[",N,"]")),new_expr);
    od:
    return new_expr;
end proc:

sol:=dsolve(diff(x(t),t$3) = x(t));
tmp:=replace_all_C(sol)

x(t) = _C1*exp(t)+_C2*exp(-(1/2)*t)*sin((1/2)*3^(1/2)*t)+_C3*exp(-(1/2)*t)*cos((1/2)*3^(1/2)*t)

x(t) = c[1]*exp(t)+c[2]*exp(-(1/2)*t)*sin((1/2)*3^(1/2)*t)+c[3]*exp(-(1/2)*t)*cos((1/2)*3^(1/2)*t)

 


 

Download q.mw

And now I get the latex of tmp in the above, instead of sol which looks better.

 

 

Hello! Sorry if this question was already asked, I just can't find my answer and I don't really know how to form the question since I'm new to using Maple. My question is: How can I find a point on a plot I did in Maple? When I use the cursor position(from when I click Probe info) I can never align it right enough for me to not get a decimal answer. For instance, I can't figure out the y-value for when x=2 because the closest I can get to 2 is like 2.1 which isn't exact enough for me. 

First 36 37 38 39 40 41 42 Last Page 38 of 56