Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

How do I work with polynomials over finite fields?  not just the integers mod p but over  https://www.maplesoft.com/support/help/Maple/view.aspx?path=GF

So what is the Maple equivalent of  functions/scripts?   and how do I call them?   like I have define the function f in the worksheet (in a code edit region) , but f(2)  just returns f(2)  no function evaluation.  

p.s. can someone recommend a guide on programming in maple?  Like writing and calling functions not   their standard programming guide which is long winded and not helpful.

 

Hi there!

Sorry to ask, but I don't know how I can solve it in a smart way. I want to take the covariant derivative of a specific vector, whose components are specifically defined, which can be constant or some functions of the coordinates. But, as soon as I define that specific vector, the covariant derivative fails to compute, saying there are "too many levels of recursion". Let me show what I mean.

I have these two attempts to get this:

 

First attempt

 

restart

with(Physics)

Setup(mathematicalnotation = true)

Coordinates(X = spherical)

{X}

(1.1)

Parameters(k)

{k}

(1.2)

Setup(metric = {(1, 1) = a(t)^2/(-k*r^2+1), (2, 2) = (a(t)*r)^2, (3, 3) = (a(t)*r*sin(theta))^2, (4, 4) = -1})

[metric = {(1, 1) = a(t)^2/(-k*r^2+1), (2, 2) = a(t)^2*r^2, (3, 3) = a(t)^2*r^2*sin(theta)^2, (4, 4) = -1}]

(1.3)

Define(b[mu])

{Physics:-D_[mu], Physics:-Dgamma[mu], Physics:-Psigma[mu], Physics:-Ricci[mu, nu], Physics:-Riemann[mu, nu, alpha, beta], Physics:-Weyl[mu, nu, alpha, beta], b[mu], Physics:-d_[mu], Physics:-g_[mu, nu], Physics:-Christoffel[mu, nu, alpha], Physics:-Einstein[mu, nu], Physics:-LeviCivita[alpha, beta, mu, nu], Physics:-SpaceTimeVector[mu](X)}

(1.4)

NULL

Define(Db[nu, mu] = D_[nu](b[mu](X)))NULL

{Physics:-D_[mu], Db[nu, mu], Physics:-Dgamma[mu], Physics:-Psigma[mu], Physics:-Ricci[mu, nu], Physics:-Riemann[mu, nu, alpha, beta], Physics:-Weyl[mu, nu, alpha, beta], b[mu], Physics:-d_[mu], Physics:-g_[mu, nu], Physics:-Christoffel[mu, nu, alpha], Physics:-Einstein[mu, nu], Physics:-LeviCivita[alpha, beta, mu, nu], Physics:-SpaceTimeVector[mu](X)}

(1.5)

Define(b[mu] = [0, 0, 0, beta], redo)

{Physics:-D_[mu], Db[nu, mu], Physics:-Dgamma[mu], Physics:-Psigma[mu], Physics:-Ricci[mu, nu], Physics:-Riemann[mu, nu, alpha, beta], Physics:-Weyl[mu, nu, alpha, beta], b[mu], Physics:-d_[mu], Physics:-g_[mu, nu], Physics:-Christoffel[mu, nu, alpha], Physics:-Einstein[mu, nu], Physics:-LeviCivita[alpha, beta, mu, nu], Physics:-SpaceTimeVector[mu](X)}

(1.6)

Db[]

Db[mu, nu] = Matrix(%id = 18446746372997772822)

(1.7)

beta := proc (X) options operator, arrow; b0 end proc``

proc (X) options operator, arrow; b0 end proc

(1.8)

Define(b[mu] = [0, 0, 0, beta], redo)

{Physics:-D_[mu], Db[nu, mu], Physics:-Dgamma[mu], Physics:-Psigma[mu], Physics:-Ricci[mu, nu], Physics:-Riemann[mu, nu, alpha, beta], Physics:-Weyl[mu, nu, alpha, beta], b[mu], Physics:-d_[mu], Physics:-g_[mu, nu], Physics:-Christoffel[mu, nu, alpha], Physics:-Einstein[mu, nu], Physics:-LeviCivita[alpha, beta, mu, nu], Physics:-SpaceTimeVector[mu](X)}

(1.9)

Db[]

Error, (in index/PhysicsTensor) too many levels of recursion

 

````

Second attempt

 

restart

with(Physics)

Setup(mathematicalnotation = true)

Coordinates(X = spherical)

{X}

(2.1)

Parameters(beta, k)

{beta, k}

(2.2)

Setup(metric = {(1, 1) = a(t)^2/(-k*r^2+1), (2, 2) = (a(t)*r)^2, (3, 3) = (a(t)*r*sin(theta))^2, (4, 4) = -1})

[metric = {(1, 1) = a(t)^2/(-k*r^2+1), (2, 2) = a(t)^2*r^2, (3, 3) = a(t)^2*r^2*sin(theta)^2, (4, 4) = -1}]

(2.3)

Define(b[mu])

{Physics:-D_[mu], Physics:-Dgamma[mu], Physics:-Psigma[mu], Physics:-Ricci[mu, nu], Physics:-Riemann[mu, nu, alpha, beta], Physics:-Weyl[mu, nu, alpha, beta], b[mu], Physics:-d_[mu], Physics:-g_[mu, nu], Physics:-Christoffel[mu, nu, alpha], Physics:-Einstein[mu, nu], Physics:-LeviCivita[alpha, beta, mu, nu], Physics:-SpaceTimeVector[mu](X)}

(2.4)

``

Define(Db[nu, mu] = D_[nu](b[mu](X)))``

{Physics:-D_[mu], Db[nu, mu], Physics:-Dgamma[mu], Physics:-Psigma[mu], Physics:-Ricci[mu, nu], Physics:-Riemann[mu, nu, alpha, beta], Physics:-Weyl[mu, nu, alpha, beta], b[mu], Physics:-d_[mu], Physics:-g_[mu, nu], Physics:-Christoffel[mu, nu, alpha], Physics:-Einstein[mu, nu], Physics:-LeviCivita[alpha, beta, mu, nu], Physics:-SpaceTimeVector[mu](X)}

(2.5)

Define(b[mu] = [0, 0, 0, beta], redo)

{Physics:-D_[mu], Db[nu, mu], Physics:-Dgamma[mu], Physics:-Psigma[mu], Physics:-Ricci[mu, nu], Physics:-Riemann[mu, nu, alpha, beta], Physics:-Weyl[mu, nu, alpha, beta], b[mu], Physics:-d_[mu], Physics:-g_[mu, nu], Physics:-Christoffel[mu, nu, alpha], Physics:-Einstein[mu, nu], Physics:-LeviCivita[alpha, beta, mu, nu], Physics:-SpaceTimeVector[mu](X)}

(2.6)

Db[]

Error, (in index/PhysicsTensor) too many levels of recursion

 

````

``

On my first attempt, expression (1.7) is almost fine, but β is supposed to be constant (and a function of "t" in the future), so I set it as a constant function. But then it causes that problem. Therefore, on my second attempt, I tried to set β as a parameter since the beginning, but it was no good either.


If I were to take the covariant derivative as "D_[nu](b[mu])" (without the "(X)"), it would not have that specific problem, but would not be a good solution, since the covariant derivative would discard the partial derivative of b[mu] and, if it would have some dependence on the coordinates, it would give a wrong result.


The only way it seems to work is by defining the tensor "Db[mu,nu]" explicitly as "d_[mu](b[nu](X)) - Christoffel[~alpha, mu, nu]*b[alpha]". (It seems that the problem comes from that "(X)" next to "b[alpha]" in the connection term.) But that would be an awful way to circumvent the problem. Isn't there any better way to get this?


Can someone help me with this, please?


Thanks for any help!

 

Download Cov._derivative_of_a_specific_vector.mw

 

We recently had a question about using some of the plotting commands in Maple to draw things. We were feeling creative and thought why not take it a step further and draw something in 3D.

Using the geom3d, plottools, and plots packages we decided to make a gingerbread house.

To make the base of the house we decided to use 2 cubes, as these would give us additional lines and segments for the icing on the house.

point(p__1,[2,3,2]):
point(p__2,[3,3,2]):
cube(c1,p__1,2):
cube(c2,p__2,2):
base:=draw([c1,c2],color=tan);

Using the same cubes but changing the style to be wireframe and point we made some icing lines and decorations for the gingerbread house.

base_decor1:=draw([c1,c2],style=wireframe,thickness=3,color=red,transparency=0.2):
base_decor2:=draw([c1,c2],style=wireframe,thickness=10,color=green,linestyle=dot):
base_decor3:=draw([c1,c2],style=point,thickness=2,color="Silver",symbol=sphere):
base_decor:=display(base_decor1,base_decor2,base_decor3);

To create the roof we found the vertices of the cubes and used those to find the top corners of the base.

v1:=vertices(c1):
v2:=vertices(c2):
pc1:=seq(point(pc1||i,v1[i]),i=1..nops(v1)):
pc2:=seq(point(pc2||i,v2[i]),i=1..nops(v2)):
topCorners:=[pc1[5],pc1[6],pc2[1],pc2[2]]:
d1:=draw(topCorners):

Using these top corners we found the midpoints (where the peak of the roof would be) and added the roof height to the coordinates.

midpoint(lc1,topCorners[1],topCorners[2]):
detail(lc1);

point(cc1,[-(2*sqrt(3))/3 + 2, (2*sqrt(3))/3 + 3+1, 2]):
d3:=draw(cc1):

midpoint(lc2,topCorners[3],topCorners[4]):
detail(lc2);

point(cc2,[(2*sqrt(3))/3 + 3, (2*sqrt(3))/3 + 3+1, 2]):
d4:=draw(cc2):

With the midpoints and vertices at the front and rear of the house we made two triangles for the attic of the gingerbread house.

triangle(tf,[topCorners[1],topCorners[2],cc1]):
front:=draw(tf,color=brown):

triangle(tb,[topCorners[3],topCorners[4],cc2]):
back:=draw(tb,color=tan):

Using these same points again we made more triangles to be the roof.

triangle(trl,[cc1,cc2,pc1[5]]):
triangle(trh,[pc2[2],pc1[6],cc1]):
triangle(tll,[cc1,cc2,pc2[2]]):
triangle(tlh,[pc2[1],pc1[5],cc2]):
roof:=draw([trl,trh,tll,tlh],color="Chocolate");

Our gingerbread house now had four walls, a roof, and icing, but no door. Creating the door was as easy as making a parallelepiped, but what is a door without more icing?

door:=display(plottools:-parallelepiped([1,0,0],[0,1.2,0],[0,0,0.8],[0.8,1.9,1.6]),color="DarkRed"):
door_decor1:=display(plottools:-parallelepiped([1,0,0],[0,1.2,0],[0,0,0.8],[0.8,1.9,1.6]),color="Gold",style=line):
door_decor2:=display(plottools:-parallelepiped([1,0,0],[0,1.2,0],[0,0,0.8],[0.8,1.9,1.6]),color="Silver", style=line,linestyle=dot,thickness=5):
door_decor:=display(door_decor1,door_decor2):

Now having a door we could have left it like this, but what better way to decorate a gingerbread house than with candy canes? Naturally, if we were going to have one candy cane we were going to have lots of candy canes. To facilitate this we made a candy cane procedure.

candy_pole:=proc(c:=[0,0,0], {segR:=0.1}, {segH:=0.1}, {segn:=7}, {tilt_theta:=0}, {theta:=0}, {arch:=true}, {flip:=false})
local cane1,cane2,cane_s,cane_c,cane0,cane,i,cl,cd,ch, cane_a,tmp,cane_ac,cane_a1,cane00,cane01,cane02,cane_a1s,tmp2,cane_a2s:
uses plots,geom3d:
cl:=c[1]:
cd:=c[2]:
ch:=c[3]:
cane1:=plottools:-cylinder([cd, ch, cl], segR, segH,style=surface):

cane2:=display(plottools:-rotate(cane1,Pi/2,[[cd,ch,cl],[cd+1,ch,cl]])):
cane_s:=[cane2,seq(display(plottools:-translate(cane2,0,segH*i,0)),i=1..segn-1)]:
cane_c:=seq(ifelse(type(i,odd),red,white),i=1..segn):

cane0:=display(cane_s,color=[cane_c]):

if arch then

cane_a:=plottools:-translate(cane2,0,segH*segn-segH/2,0):
tmp:=i->plottools:-rotate(cane_a,i*Pi/24, [ [cd,ch+segH*segn-segH/2,cl+segR*2] , [cd+1,ch+segH*segn-segH/2,cl+segR*2] ] ):

cane_ac:=seq(ifelse(type(i,odd),red,white),i=1..24):

                cane_a1s:=seq(plottools:-translate(tmp(i),0,segH*i/12,segR*i/4),i=1..12):

tmp2:=i->plottools:-rotate(cane_a1s[12],i*Pi/24,[[cd,ch+segH*segn-0.05,cl+segR*2],[cd+1,ch+segH*segn-0.05,cl+segR*2]]):

cane_a2s:=seq(plottools:-translate(tmp2(i),0,-segH*i/500,segR*i/4),i=1..12):
cane_a1:=display(cane_a1s,cane_a2s,color=[cane_ac]):
cane00:=display(cane0,cane_a1);

                if flip then

cane01:=plottools:-rotate(cane00,tilt_theta,[[cd,ch,cl],[cd+1,ch,cl]]):
cane02:=plottools:-rotate(cane01,theta,[[cd,ch,cl],[cd,ch+1,cl]]):
cane:=plottools:-reflect(cane01,[[cd,ch,cl],[cd,ch+1,cl]]):

                else

cane01:=plottools:-rotate(cane00,tilt_theta,[[cd,ch,cl],[cd+1,ch,cl]]):
cane:=plottools:-rotate(cane01,theta,[[cd,ch,cl],[cd,ch+1,cl]]):

                end if:

                return cane:

else

                cane:=plottools:-rotate(cane0,tilt_theta,[[cd,ch,cl],[cd+1,ch,cl]]):

                return cane:

end if:

end proc:

With this procedure we decided to add candy canes to the front, back, and sides of the gingerbread house. In addition we added two candy poles.

Candy Canes in front of the house:

cane1:=candy_pole([1.2,0,2],segn=9,arch=false):
cane2:=candy_pole([2.8,0,2],segn=9,arch=false):
cane3:=candy_pole([2.7,0.8,3.3],segn=9,segR=0.05,tilt_theta=-Pi/7):
cane4:=candy_pole([1.3,0.8,3.3],segn=9,segR=0.05,tilt_theta=-Pi/7,flip=true):
front_canes:=display(cane1,cane2,cane3,cane4):

Candy Canes at the back of the house:

caneb3:=candy_pole([1.5,4.2,2.5],segn=15,segR=0.05,tilt_theta=-Pi/3,flip=true):
caneb4:=candy_pole([2.5,4.2,2.5],segn=15,segR=0.05,tilt_theta=-Pi/3):}
back_canes:=display(caneb3,caneb4):

Candy Canes at the left of the house:

canel1:=candy_pole([0.8,1.5,2.5],segn=15,segR=0.05,tilt_theta=-Pi/7,theta=Pi/2):
canel2:=candy_pole([0.8,2.5,2.5],segn=15,segR=0.05,tilt_theta=-Pi/7,theta=Pi/2):
canel3:=candy_pole([0.8,4,2.5],segn=15,segR=0.05,tilt_theta=-Pi/7,theta=Pi/2):
left_canes:=display(canel1,canel2,canel3):

Candy Canes at the right of the house:

caner1:=candy_pole([3.2,1.5,2.5],segn=15,segR=0.05,tilt_theta=-Pi/7,theta=Pi/2):
caner2:=candy_pole([3.2,2.5,2.5],segn=15,segR=0.05,tilt_theta=-Pi/7,theta=Pi/2):
caner3:=candy_pole([3.2,4,2.5],segn=15,segR=0.05,tilt_theta=-Pi/7,theta=Pi/2):
right_canes:=display(caner1,caner2,caner3):

canes:=display(front_canes,back_canes,right_canes,left_canes):

With these canes in place all that was left was to create the ground and display our Gingerbread House.

ground:=display(plottools:-parallelepiped([5,0,0],[0,0.5,0],[0,0,4],[0,1.35,0]),color="DarkGreen"):

display([door,door_decor,d1,base,base_decor,d3,d4,front,back,roof,ground,canes],orientation=[-100,0,95]);

You can download the full worksheet creating the gingerbread house below:

Geometry_Gingerbread.mw

I rename text file as mws when I click it , it show a few button and then need to extra click maple input and then need to click enter in order to run.

 

how to run directly when I open it with maple?

For a spring hanging vertically from a fixed point, suppose the spring constant, k, is a function of the distance from the fixed point to the other (lowest) end of the spring (for example; the diameter of the spring's coils changes along the length of the spring) .

What ODE reflecting this situation will yield solutions for the harmonic motion of the spring after it is stretched from its equilibrium position?

In Maple 2019, I'm using the "applyrule" function to write a simple routine for contracting vector indices, following the Einstein summation convention (repeated indices are summed).

Input:

applyrule(
  vec(a::symbol, i::symbol) * vec(b::symbol, i::symbol) = dotproduct(a,b),
  vec(a,k) * vec(b,k)
);

Output:

dotproduct(a, b)

So far it works as expected. Now I add an "uncontracted" vector, and the code seems to become unpredictable. First, let me show a case in which the code still works:

Input:

applyrule(
  vec(a::symbol, i::symbol) * vec(b::symbol, i::symbol) = dotproduct(a,b),
  vec(u,k) * vec(u,i) * vec(c,k)
);

Output:

dotproduct(c, u)*vec(u, i)

As expected, contraction has been done on the repeated index "k", but vec(u,i) was left alone. However, the above code fails if I simply change the variable name "u" to "a":

Input:

applyrule(
  vec(a::symbol, i::symbol) * vec(b::symbol, i::symbol) = dotproduct(a,b),
  vec(a,k) * vec(a,i) * vec(c,k)
);

Output:

vec(a, k)*vec(a, i)*vec(c, k)

Apparently, the rule was not applied because I used "a:symbol" in the transformation rule. But I thought "a::symbol" should be considered a wildcard that represents any symbol, including "a" itself?

Depending on the exact input, this bug sometimes shows up, sometimes not, but the above examples are verified to be reproducible. A simple workaround is always avoiding the use of the same variable, but this seems to be hack. Is there a proper solution?

How can add a PNG within a text section of a Maple Worksheet without having the image appear with a black background?

Does Maple have an alpha channel or transparency setting that must be toggled for this to work?

Maple 2019
macOS 10.14.6

I am added pictures from the clipboard via drag+drop.

(Yes, I know that I can use JPEG without this problem and that is NOT my question).

--
JJW

hi . i want to get maximize in dsolve numeric y(t) D(y)(t) and y(t) double dot

restart;
with(plots);
with(Optimization);
sol := {diff(y(t), t, t) + 2*diff(y(t), t) + 4*y(t) = 0.9*sin(9*t), y(0) = 0, D(y)(0) = 0};
so := dsolve(sol, numeric, method = rkf45);
plots:-odeplot(so, [t, y(t)], t = 0 .. 4);
Maximize(??????);
 

I find eval(Diff(x,x)) still is Diff(x,x)

how to make become 1

or how to evaluate Capital Diff ?

 

and I find sum(diff(x^k,x)/k! , k=1..n)

return exp(x) *gamma(n,x)/gamma(n)

why not exp(x)?

 

and diff( m(x+ diff(...) ...) / diff without m(x) , why return 0

i still have not define m(x)

 

I am very pleased to announce that we have released a new version of the free Maple Companion app. For those you may have missed it, the first release of this app gave you a way to take a picture of math using your phone’s camera and upload it into Maple. Instructors have told me they’ve found this very useful in their classes, as they no longer have to deal with transcription errors as students enter problems into Maple.

So that’s good. But version 2 is a lot better. The Maple Companion now solves math problems directly on your phone. It can handle problems from algebra, precalculus, calculus, linear algebra, differential equations, and more. No need to upload to Maple – students can solve the problem by hand, and then use the app to check their answer, try new operations on the same expression, and even create plots. And if they want to do even more, they can still upload the expression into Maple for more advanced operations and explorations.

There’s also a built-in math editor, so you can enter problems without the camera, too. And if you use the camera, and it misinterprets part of your expression, you can fix it using the editor instead of having to retake the picture.  Good as the math recognition is, even in the face of some pretty poor handwriting, the ability to tweak the results has proven to be extremely useful.

There’s lots more we’d like to do with the Maple Companion app over time, and we’d like hear your thoughts, as well. How else can it help students learn?  How else can it act as a complement to Maple? Let us know!

Visit Maple Companion to learn more, find links to the app stores so you can download the app, and access the feedback form. And if you already have version 1, you can get the new release simply by updating the app on your phone.

 

I know how to define functions and generally how to pass them to another function and usually everything works out... rarely though I run in to problems and my lack of how maple works internally becomes a stumbling block. I usually just hack things together. I'd rather understand what exactly is happening.

 

It seems that apply and unapply have something to do with this.

 

I usually define functions like this, e.g.,

 

f := x->x^2 + 3;

g := (f,x)->cos(f(x));

 

and things like g(f,x) work as expected.

But this doesn't always work.

 

E := proc(f, depth)
    if depth <= 0 then return f; fi:
     E(f(x), depth-1); # Trying to actually compute f(f(x)), say. I know we can just loop.
end proc:


E(x->2*x, 3);

2*x(x)(x)

 

rather than 8x

 

I see that maple is somehow applying the function but in some odd way(it seems to be creating a function from the variable x and then another function from that).

 

Anyways, I don't understand the mechanics of it. In some cases f works other one must add the variablef(x), etc...

 

There seems to be some subtle difference between f and f(x)...  In a programing language like C. f is sort of a function pointer and f(x) is an evaluation of f at x. I guess there is something similar goingn on with maple but i've not been able to figure it out. Any ideas?

I have been able implement this procedure here. 

AreaBetween := overload([proc(fnc::{list}, a::anything, b::anything, col::list) option overload; plottools:-transform(unapply([x, y + fnc[2]], x, y))(plot([fnc[1]] + [-fnc[2]], x = a .. b, col = [col[2], col[3]], gridlines, size = [600, 600], thickness = 3, filled = [color = col[1]])); end proc])

1) How do get to construct a larger canvas? Meaning if I want a xy axis, x = -10..10, y = -10..10 however only x = a..b is suppose to be shaded. Can I do that with my procedure? 

2) Only the lower graph is colored currently. How do I get it to color the upper graph? 

Many thanks in advance. 

Hello;

Maple 2019.2.1 on windows 10

Is there a trick to make inttrans:-fourier(erf(x),x,k) return the Fourier transform of the error function? Now, using Maple 2019.2.1 it returns unevaluated. But direct application of Fourier transform integral does return the correct result. So why inttrans does not work? 
 

inttrans:-fourier(erf(x),x,k)

fourier(erf(x), x, k)

1/sqrt(2*Pi)*int(erf(x)*exp(-I*x*k),x=-infinity..infinity)

-I*2^(1/2)*exp(-(1/4)*k^2)/(Pi^(1/2)*k)

 

 

Download erf.mw

 

 

 

Hi,


I have a set of functions of the form P :=  { a(t), b(t), f(g(t)), u(v(w(t)), A(a(t), b(t)), ... } and I want to obtain the set Q := { a(t), b(t), g(t), w(t) } (that is the set of the innermost functions)
Since more than an hour I'm fighting without success with select and parmatch and I'm desperatly askink for your help.

Thanks in advance
 
PS : the list P only contains functions of t, never of t and of another variables.

1 2 3 4 5 6 7 Last Page 1 of 1614