Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Study a example 

Procedures. Declare local variables within procedures.
> # Program 1: Procedures.
> # The norm of a 3-dimensional vector.
> norm3d:=proc() local a,b,c;sqrt(aˆ2+bˆ2+cˆ2) end;
> norm3d(3,4,5);
5√(2)

Must say it was never clear for me the procedure () 
Never have read in the tutorials or study material the use of proc ( )  ( i did not read them all, so probably i missed it somewhere )

The procedure norm3d()  i get not working , because i don't not know how to use it 

 

What do I need to do to the "2 + 3" in the attached Document in order to make it evaluate? I know about F5 to switch between Text and Math modes, but that's not enough to get me where I want to be. The "2 + 3" is already in Math mode, but that's not enough to get it to evaluate.

The Document: t.mw

I would appreciate seeing how Maple handles concatenation, digital sums and selection of related least terms. Here are two examples of problems currently of interest:

1. Construct the lexicographically earliest sequence of distinct positive integers such that the sum of the digits of the first n terms is coprime to their concatenation; first term is 1:

1,3,7,2,4,5,9,6,13,8,19,11....

(I already have many terms for this, computed by a  Mathematica code, but would like to see it done in Maple).

2. Lexicographically earliest sequence of distinct positive integers such that the n-th term divides the concatenation of the first n terms; first term is 1:

1,2,3,5,10,4,8,6,11,20,13,7,9,12,15,18,14,25,30.....

(these terms found one by one, using Maple in manual mode, no code).

Thanks in advance for any assistance with this 

Regards

David.

 

 

Is there a possibility to test the result of a numerically solved deq?

Something goes wrong in this worksheet with old code

Must be corrected
Thanks

fmatrix.mws

Anyone maybe helps me with writing the maple code mentioned in the following pdf.

I want to know about the potential flow around 3D domain.

 

Doc1.pdf

R2,R3,R4,R5 have been given,I try to solve the following ode equation: The initial value:r2(0)=r3(0)=r4(0)=r5#(0);system={diff(r2(theta),theta)=R2;diff(r3(theta),theta)=2*R2*U2+R3;diff(r4(theta),theta)=R2*(U2^2+2*U3)+3*R3*U2+R4;diff(r5(theta),theta)=2*R2*(U2*U3+U4)+3*R3*(U2^2+U3)+4*R4*U2+R5}.I want to get the exact solution of subs(theta=2*Pi,U5),But it just gives the form include _Z1,_Z_2,_Z3.How can I get exact value?
 

restart:

#interface(echo = 2)

c10:=-26/9:c01:=-9.330480048:c11:=-199/33:c02:=-7.162134941:c12:=-93/11:c03:=-.756797589:d10:=11/9:d01:=26/9:d11:=19/3:d02:=25/3:d12:=8:d03:=1:

 

 

A1 := c03*y^3+c12*x*y^2+c02*y^2+c11*x*y+c01*y+c10*x:B1:=d03*y^3+d12*x*y^2+d02*y^2+d11*x*y+d01*y+d10*x:

aa1:=diff(arctan(v/u),u):bb1:=diff(arctan(v/u),v):

  A11:= subs({x = -u, y = (v+c10*u/sqrt(w))*sqrt(w)/c01}, -A1):B11:= subs({x = -u, y = (v+c10*u/sqrt(w))*sqrt(w)/c01}, B1):

w :=-c01*d10+c10*d01:

f11 := subs({x = -u, y = (v+c10*u/sqrt(w))*sqrt(w)/c01}, -A1): collect(%, v):f2 := subs({x = -u, y = (v+c10*u/sqrt(w))*sqrt(w)/c01}, B1): collect(%, v):g := simplify(-c10*f11/sqrt(w)+c01*f2/sqrt(w)): collect(%, v):

f111:=collect(1/sqrt(w)*f11,v):f222:=collect(1/sqrt(w)*g,v):

F1:=u*f111+v*f222:F11:=subs({u=r*cos(theta),v=r*sin(theta)},F1):F11:=F11/r:F2:=aa1*f111+bb1*f222:F22:=subs({u=r*cos(theta),v=r*sin(theta)},F2):

M:=F11/F22:M:=taylor(M,r,6):r1:=coeff(M,r,1):simplify(%):subs(c10=-d01,r1):simplify(%):

 

c10:=-d01:R2:=coeff(M,r,2):R3:=coeff(M,r,3):R4:=coeff(M,r,4):R5:=coeff(M,r,5):

 

#R2,R3,R4,R5 have been given,I try to solve the following ode equation: The initial value:r2(0)=r3(0)=r4(0)=r5#(0);system={diff(r2(theta),theta)=R2;diff(r3(theta),theta)=2*R2*U2+R3;diff(r4(theta),theta)=R2*(U2^2+2*U3)+3*R3*U2+R4;diff(r5(theta),theta)=2*R2*(U2*U3+U4)+3*R3*(U2^2+U3)+4*R4*U2+R5}.I want to get the exact solution of subs(theta=2*Pi,U5),But it just gives the form include _Z1,_Z_2,_Z3.How can I get exact value?

 

U2:=rhs(dsolve({diff(r2(theta),theta)=R2,r2(0)=0})):

U3:=rhs(dsolve({diff(r3(theta),theta)=2*R2*U2+R3,r3(0)=0})):

U4:=rhs(dsolve({diff(r4(theta),theta)=R2*(U2^2+2*U3)+3*R3*U2+R4,r4(0)=0})):

U5:=rhs(dsolve({diff(r5(theta),theta)=2*R2*(U2*U3+U4)+3*R3*(U2^2+U3)+4*R4*U2+R5,r5(0)=0})):

U6:=subs(theta=2*Pi,U5):save U6, output5:

 

 

``


 

Download Li2.mw
 

 

How to turn the "a" into a number before it gets plotted? Here's how not to do it:

 

eval(plot(x, x = 0 .. a), a = 3);
Error, (in plot) expecting a real constant as range endpoint but received a
subs(plot(x, x = 0 .. a), a = 3);
Error, (in plot) expecting a real constant as range endpoint but received a

 

My limited experience with Maple graphics consists so far of plotting simple graphs using plot(). Now I'd like to do one like this (digital signal-processing: discretely sampling a continuous signal):

In addition to the graph of the continuous function, I've drawn dots on the graph at integer x-values, and then I've dropped verticals from the dots to the x-axis.

There will always be a dot on the graph at x=0, and the horizontal distance from one dot to the next will always be constant within a single graph, but not always equal to 1. For example, in one graph the dots might be spaced 0, Pi, 2*Pi, etc. It would be nice to show numerical labels for the x-values of the dots in that case too.

What functions should I read about in the docs for this? Thank you.

1. The attached file is a small test sample out of a larger program. I do not understand what is wrong with the code.

2. What does 'global variables are deprecated' mean when I want to solve a deq numerically? Cannot acces link indicated for further explanation.

3. Is there a means to use 'odetest' when a deq was solved numerically?

 

Dear everyone,

I want to execute a simple example by using Grid:-Send and Grid:-Receive commands. I have two questions:
1) Why does the Grid:-GetLastResult(0) command not return anything?

2) I tried to send the value of a, namely 2, from node 0 to node 1. It seems the execution is not stopped by Grid:-Send(1,a) and a_1:=Grid:-Receive(0) while CPU is not working.
Would anyone guide me?

The answer to the second question is more important to me.

Best wishes

 

 

restart;

Grid:-Run(0,"a:=2;");

Grid:-GetLastResult(0);

Grid:-Get(0,a);

Grid:-Send(1,a);

a_1:=Grid:-Receive(0);

The Maple Units implementation is really causing a lot of trouble.

Right now I'm getting results in Joule, but I want to convert to kN*m.

Can someone explain to me this?

Without loading Units, conversion works.

When loading Units, regardless of simple or standard, it doesn't work anymore.

 

Don't get a DEplot 


 

with(DEtools,DEplot);with(plots,display);

[DEplot]

 

[display]

(1)

 

 

 

init3:=seq([0,k*0.2,0],k=-4..10);

[0, -.8, 0], [0, -.6, 0], [0, -.4, 0], [0, -.2, 0], [0, 0., 0], [0, .2, 0], [0, .4, 0], [0, .6, 0], [0, .8, 0], [0, 1.0, 0], [0, 1.2, 0], [0, 1.4, 0], [0, 1.6, 0], [0, 1.8, 0], [0, 2.0, 0]

(2)

 

The forward plot is p3:

 

p3:=DEplot([sys],[x,y],t=0..2,[init3],x=-3..2,y=-3..2,stepsize=.05,arrows=none,linecolor=black,thickness=1,axes=box,scaling=constrained):

Error, (in f) numeric exception: division by zero

 

he backward plot is np3:

 

np3:=DEplot([sys],[x,y],t=-2..0,[init3],x=-3..2,y=-3..2,stepsize=.05,arrows=none,linecolor=black,thickness=1,axes=box,scaling=constrained):

Warning, plot may be incomplete, the following errors(s) were issued:
   cannot evaluate the solution further left of -.29861232, probably a singularity
Warning, plot may be incomplete, the following errors(s) were issued:
   cannot evaluate the solution further left of -.93147185e-1, probably a singularity
Warning, plot may be incomplete, the following errors(s) were issued:
   cannot evaluate the solution further left of -.23648931e-1, probably a singularity
Warning, plot may be incomplete, the following errors(s) were issued:
   cannot evaluate the solution further left of -.27325542e-2, probably a singularity

 

Error, (in f) numeric exception: division by zero

 

 

display({p1,p2,p3,np3});

Error, (in plots:-display) expecting plot structures but received: {np3}

 

 


 

Download uitzoeken_ode_lesmateriaal_betounes_of_het_werkt.mw

Maple can return multiple values as expression sequence. The problem with this is that if one of the values is NULL, then one gets an error on the receiving end.

For example, suppose a proc foo() is meant to return 3 separate values. When doing 

  a,b,c := foo() 

This will fail if one of the values was NULL. For example, if b  was NULL, then Maple returns a,c only. The NULL value is discarded.

foo:=proc()
 local a,b,c;
  a:=1; b:=NULL; c:=3;
  return a,b,c;
end proc;

a,b,c := foo()

Error, mismatched multiple assignment of 3 variables on the left side and 2 values on the right side

I'd like to use NULL to indicate that this variable has no value (may be it could be something that could not be computed inside foo, or some solution that could not be found, and for any other reason.)

So currently I use {} instead of NULL everywhere to indicate no value for that variable and that works

foo:=proc()
 local a,b,c;
  a:=1; b:={}; c:=3;
  return a,b,c;
end proc;

a,b,c := foo()

And now I check using if b={} instead of if b=NULL and that works OK for what I want.

It would be nice if one could do this

  [a,b,c] := foo() 

And even if b was NULL, it will still keep that slot. But Maple will also replace [a,b,c]  with [a,c]  if b was NULL

So what is NULL used for in Maple exactly? (help says it is used to initialize an expression sequence). Since one can't return NULL as value.

In Mathematica, NULL can be returned as an actual value. For example

foo[] := Module[{a, b, c},
  a = 1; b = Null; c = 3;
  {a, b, c}
 ];

{a, b, c} = foo[]

gives

    {1, Null, 3}

My question: is using {} in place of NULL a common practice  in Maple to indicate no value for a variable being returned? Or is there a better way than this?

 

I have been using Maple 2017 but recently upgraded to MacOS Catalina. It doesn't work anymore. I would upgrade to Maple 2020, but worried will I have to upgrade again when the new MacOS 11 comes out? does anyone have any experiece dealing with similar situation on previous MacOS upgrade?

First 389 390 391 392 393 394 395 Last Page 391 of 2097