Maple 2020 Questions and Posts

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

The code 

S:=sum(1/x__i,i=1..5)

will give us the following ouput

Why not 

S:=add(1/x__i,i=1..5)

 also give same result. why?How to do?

I also note that:

S:=add(1/x||i,i=1..5)

S:=sum(1/x||i,i=1..5)

 

Hey there, I´m new to maple and running into some syntax issues when calculating the Euler-Lagrange equation.

The Euler Lagrange equation in general looks like this:

I´ve got  the Lagrangian for my task figured out:

Here´s the code for this line, be aware that the function definition part of this is not working.

L:=((x),(varphi),t)->(J)/(2)*(((x))/(R))^(2)+(`m__R`)/(2)(*(x))^(2)+(`m__p`)/(2)(((x)+l*(varphi)*cos(varphi))^(2)+(l*(varphi)*sin(varphi))^(2))+`m__p`*g*l*cos(varphi)

phi is obviously a function of t, I´m not sure if I should have written phi(t)

 

In the first step to solve the Euler-Lagrange, I have to partially differentiate L w.r.t xdot. preferably with a command something like the following:

How do I do that, how do I set L up to be able to do that? The way I defined the function above is not correct because xdot and phidot cant be used an argument apparently.

If all is working perfectly I´d be able to partially differentiate L w.r.t xdot, phidot, x, phi and subsequently be able to differentiate the first two w.r.t t again.

I´ll spare you the detail but I´ve tried for hours now with redefining xdot as xdot:= diff(x(t),t) and all sorts of other ways but nothing seems to really work.

 

Thanks for your help.

Maple will give error when one tries to make a variable of the same name as a Maple command. Which is good ofcourse. So this gives an error

Vector:=5;

But Maple also uses hundreds of other names, as options, which are not protected like this. Even when adding this

adding interface(warnlevel=4);
kernelopts('assertlevel'=2):

There was no warning when a user makes a variable of same name as one of those Maple option names.

So if a user make a variable with such a name, it will cause serious problem. For example Vector constructor takes the name row as an option. But this name is not protected. So one can write  row:=5 and there is no warning generated by Maple.

Using Vector['row'] does not actually help. Here is an example, where Maple crashes due to this

restart;
interface(warnlevel=4);
kernelopts('assertlevel'=2):
A:=Matrix([[1,1],[2,3],[4,5]]);
row:=convert([a,b],Vector['row']);
res:=ArrayTools:-Concatenate(1,A,row); #this works, no problem

ArrayTools:-Concatenate(1,A,convert([a,b],Vector['row'])); #this will crash Maple

 

A workaround this, it to use double '' in the second call. Like this:

ArrayTools:-Concatenate(1,A,convert([a,b],Vector[''row''])); 

And if this to used again, to use

ArrayTools:-Concatenate(1,A,convert([a,b],Vector['''row'''])); 

And so on.  Ofcourse this is no way to do things.

So the user should not use row as variable name. May be use the_row instead, or a_row, and so on.

But this comes back to my question. The above is a made up example. How is the user supposed to remember there is some option used by Maple somewhere with such a name and avoid using it as a variable name? 

There are may be thousands of such names in Maple, with common names, like color and so on, and it is very easy to make a variable of this name by the user without noticing.

I also tried maplemint() and it gave no warning that a user variable have the same name as a Maple option name.

restart;
interface(warnlevel=4);
kernelopts('assertlevel'=2):

foo:=proc()
local A,row,res,a,b;
A:=Matrix([[1,1],[2,3],[4,5]]);
row:=convert([a,b],Vector['row']);
res:=ArrayTools:-Concatenate(1,A,row); #this works, no problem
ArrayTools:-Concatenate(1,A,convert([a,b],Vector['row'])); #this will crash Maple
end proc;

maplemint(foo);

foo()

 

Finally, I found that if I use Vector(:-row) instead of Vector('row'), then the crash goes away and now it works

restart;
interface(warnlevel=4);
kernelopts('assertlevel'=2):

foo:=proc()
local A,row,res,a,b;
A:=Matrix([[1,1],[2,3],[4,5]]);
row:=convert([a,b],Vector[:-row]);
res:=ArrayTools:-Concatenate(1,A,row); #this works, no problem
ArrayTools:-Concatenate(1,A,convert([a,b],Vector[:-row])); #this will now work
end proc;

foo();

But this worked because there was no global variable of the name row before calling foo. That is all. To make the above crash, all what I had to do is this
 

restart;
interface(warnlevel=4);
kernelopts('assertlevel'=2):

foo:=proc()
local A,row,res,a,b;
A:=Matrix([[1,1],[2,3],[4,5]]);
row:=convert([a,b],Vector[:-row]);
res:=ArrayTools:-Concatenate(1,A,row); #this works, no problem
ArrayTools:-Concatenate(1,A,convert([a,b],Vector[:-row])); #this will now work
end proc;

row:=5;
foo();

And now it crashes again.

This is all a big mess. Maple should warn users they are using variable of same name as Maple own option names, or make all Maple option names use some standard prefix. May be have them all start with or _ and have this special first letter be allowed only for Maple own use.

This will help prevent name clashes.

In Mathematica, this issue does not happen. Since all Mathematica names and symbols used, even as options, are protected or are strings. So no such possibility of name clash happen.

Is there a 100% robust way in Maple to prevent such name clash between user variable names and names used as options to Maple commands?

 

Fyi, there seems to be some problem here

Maple 2020.2 with Physics 897

restart;
interface(warnlevel=4):
kernelopts('assertlevel'=2):
eq:=exp(x)*sin(y(x))-3*x^2+(exp(x)*cos(y(x))+(1/3)/y(x)^(2/3))*(D(y))(x) = 0;
timelimit(30,solve(eq,y(x)));

 

Full screen shot:

 



Maple Worksheet - Error

Failed to load the worksheet /maplenet/convert/solve_error.mw .
 

Download solve_error.mw

Hi,

I noticed that, in Maple 2020.2, the caracters seem smaller. As if the zoom had somewhat been reduced (a bit).

However, in the preferences, the default zoom level I would like is between 100 and 125% (something like 110%) (since the default zoom level is adjusted by steps of +/- 25%). I wondered if there was a way to set the default zoom level to an arbitrary value. In fact I thought it would be great to have a field instead of a list of choices, so we can choose a custom value.

Thank you

I was trying to plot a simple degree two curve but with one point removed. My first attempt was the following;

p1 := plot(x^2 - 1, x = -2 .. 2);
p2 := plot([[0, -1]], style = point, symbol = circle, symbolsize = 20);
plots[display](p1, p2);

But the curve line is shown even inside the circle of the removed point. Changing order of `p1` and `p2` in `plots[display]` doesn't make any changes on the output.

My second attempt was the following.

p3 := plots[display](plottools[disk]([0, -1], 0.1, color = white)):
plots[display](p1,p3);

This didn't help either.

Hello everyone,

There is a strange behaviour with code-edit. Namely, when hiding code-edit window and recovering it, sometimes Maple create a very narrow window. It is very hard to see the code that way. After a while the code-edit region window readjusts itself though. However it takes time.

Also another thing, it would be useful when searching in a worksheet, to have an option that allows to search in code-edit region also.

Best regards,

By the code

P := plot( [ sin(x)-x+(x^3)/3! ] ) :
L := plots[textplot]( [ 3 , 15 , sin(x)-x+(x^3)/3! ],  axes = none) :
plots[display]( P ,L, axes = normal )

I'd like to put the text sin(x)-x+(x^3)/3!  not  sin(x)-x+(x^3)/6   in the image.

I thought  that parse can do that

parse("sin(x)-x+(x^3)/3!")

But One use it in plots[textplot] , it is not useful!

P := plot( [ sin(x)-x+(x^3)/3! ] ) :
L := plots[textplot]( [ 3 , 15 , parse("sin(x)-x+(x^3)/3!") ],  axes = none) :
plots[display]( P ,L, axes = normal )

How to do? Thanks!

 The code

s:=solve(sin(x)=3*x/Pi,x)

gives us following output:

s := RootOf(-sin(_Z)*Pi + 3*_Z)

The allvalues command attempts to find symbolic representations of the roots using solve.
But  the code:

allvalues(s);
solve(sin(x)=3*x/Pi,x,AllSolutions)

gives us 

RootOf(-sin(_Z)*Pi + 3*_Z, 0.5235987756), RootOf(-sin(_Z)*Pi + 3*_Z, -0.5235987756), 0

RootOf(-sin(_Z)*Pi + 3*_Z)

To see the roots of sin(x)-3*x/Pi   we use plot

plot(sin(x)-3*x/Pi,x=-100..100)

 

plot(sin(x)-3*x/Pi,x=-Pi/4..Pi/4)

And we can also figure out  three roots of this function are 0  Pi/6 and -Pi/6

High probability it has no other root.

seq(eval(sin(x)-3*x/Pi,x=i),i in [-Pi/6,0,Pi/6])

0, 0, 0

Why doesn't Maple do anything about it

 

 

 

Why doesn't the graphs of alpha=0 and alpha=1  appear in the following code?

restart:
v:=t->t:
plot([seq(fracdiff(v(t), t,alpha),alpha=-1..1.5,0.5)],t=0..10,view=[0..9.5,0..5],legend=[seq('alpha'=alpha,alpha=-1..1.5,0.5)],color = [red, blue, green,yellow,cyan,magenta],axis[2]=[gridlines=[linestyle=dot]]);

 

if alpha=1;

fracdiff(t, t,alpha)

gives 1. But it doesn't appear in the figure. 

if alpha=0, 

fracdiff(t, t,alpha)

gives t. But it doesn't appear in the figure, also. 

How can i remove a section envelope ( the initial arrow and the vertical line) without removing the content.

In other words how can I liberate the content from being imprisoned in the section

 

Thank you

When doing solve(res,x); maple returns back x

Does this means the equation is true for any x?

Also, doing PDEtools:-Solve(res,x) returns nothing.

I was trying to check if my solution is valid for an ode, and I obtained res above is what odetest() gives back, I wanted to find for what could res be zero.

Here is the code

restart;
ode:=diff(y(x),x)=2*sqrt(1+y(x))*cos(x);
my_sol:=y(x)=sin(x)^2+2*sin(x);
res:=odetest(my_sol,ode);
res:=simplify(res)=0;
solve(res,x);

And now 

PDEtools:-Solve(res,x)

gives nothing.

So I am a little confused what is going on. does solve result mean the equation is true for any (I think the solution I have is correct, so may be what this means,  but wanted to make sure, as I do not think I've seen this before)  And if so, why then PDEtools:-Solve did not return the same result.

Maple 2020.2, windows 10, Physics 897

Maple gives solution to equation as RootOf when there is no explicit solution

restart;
eq:=x*sin(x*y)+y+1=0;
sol:=solve(eq,y)

The _Z above, is the variable we wanted to solve for, which is in this example. My question is, why did not Maple give the solution as

sol2:=RootOf(x*sin(_Z*x)+_Z+1)

Which is a little simpler looking. Is the above not the same as what Maple gives?  I just replace by _Z 

Digits:=100;
plot(evalf(sol-sol2),x=0..Pi)

The uploaded worksheet contains the general definition of a pedal curve related to the curve [f(t),g(t)], and includes several example pedal curves.

Is there a comparable general definition of a pedal surface? If so, in your answer please include the Maple code for one or two simple examples e.g. relating to a sphere, to an ellipsoid.

To everyone in the Maple Forum community, Happy Holidays and a fulfilling New Year!

Pedal_curves.mw 

sometimes Maple's solution for an ode is not valid for all x. When I run odetest on the solution, it is not zero.

For the case when the output of odetest contains one csgn(), I am trying to determine if odetest result will become zero, when csgn is +1  or -1. If so, then next look into the argument of csgn and solve for x under this condition and hence find the range of x when the solution is valid.

I wrote the following to do this and check the idea.

I'd like to ask if the Maple experts here can suggest improvement or if there a better way to do this.

The code below works if there is only instance of csgn() in the output of odetest. Which covers almost all the cases I saw so far.

The code first checks if csgn is present in the output of odetest. If so, it then uses indents to pick up the function csgn out. Then uses op to pick its argument. Then uses solve with inquality to find when the argument is either positive or negative. This results in the range of x needed to make odetest zero.

This is just a quick prototype to test the idea. This not the final code I will be using as that will include more checks and be more robust. 

restart;
ode :=diff(y(x),x)=2*(x*sqrt(y(x))-1)*y(x):
ic  :=y(0)=1:
sol :=dsolve([ode,ic]):
res :=odetest(sol,ode);

So we see odetest did not give zero.  The issue is that I can't just do 

solve(res=0,x)

It does not work.  So that is why I had to look inside as follows:

The goal is to check if when csgn is either +1 or -1, if it will then become zero.

And if so, then also find the range of x which will caused this.  In the above, we see that when 1/(x+1) is +1, then odetest result  will become zero. This means x has to be larger than -1.

Note that this is all done in code, without being able to look at the screen and then decide what to do

if res<>0 then
    if has(res,csgn) then
        if simplify( subsindets(res,csgn(anything),f->1)) = 0 then      
            print("the odetest becomes zero when csgn is POSITIVE");
            Z:=indets(res,specfunc(csgn));
            the_args:=map(x->op(x),Z);
            print("Now solve ",the_args," for x, when the expression is POSTIVE");
            for tmp in the_args do
                result:=solve(tmp>0,x);
                print("the solution is valid for x>", op([1,1],result));
            od;
        else
            if simplify( subsindets(res,csgn(anything),f->-1)) = 0 then      
                print("the odetest becomes zero when csgn is POSITIVE");
                indets(res,specfunc(csgn));
                the_args:=map(x->op(x),Z);
                print("Now solve ",the_args," for x, when the expression is negative");
                for tmp in the_args do
                    result:=solve(tmp<0,x);
                    print("the solution is valid for x<", op([1,1],result));
                od;
            else
                print("give up. Tried when csgn is positive or negative");
            fi;
        fi;
    fi;
fi;

If there is more than one csgn function in the odetest result, it will become much more complicated, since one have to check all combinations to find under which combination odetest will become zero. So for now, I am just doing this only for one case of csgn present.

 

First 22 23 24 25 26 27 28 Last Page 24 of 55