Maple 2020 Questions and Posts

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

 I want to find AutomorphismGroup  of star S4 (ie, K1,3).

with(GraphTheory):
with(GroupTheory):
with(SpecialGraphs):
S4:=CompleteGraph(1,3);
G1 := AutomorphismGroup(S4); # out is GroupTheory:-PermutationGroup({module() ... end module,module() ... end module},degree=4)

 

 

the S_4 has six automorphisms: (1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2,), (3, 2, 1):

GraphAutomorphismStar

For the output of maple ,I cannot understand.

Maybe I don’t understand the group enough. May somebody explain in detail,  Thanks!

ode.mw

I found an assignment question concerning an ODE from 20 years ago. This was before I had discovered Maple.

So I put it through Maple and got a complex solution, But the lecturer's solution was non-imaginary.

For a) gamma <> Beta and b) gamma = beta.

Actually for b) I couldn't follow his solution

 

Consider

restart;
L := [1,2,3,4];
x[j];
seq(%, x[j] in L);
x[j];

What would you expect the output of the last line to be?

Answer:   Maple says 4.   Why?

 

 

This proc is valid, yet Maple mint thinks there is syntax error

foo:= proc(x)
local z := "";
    if not x in ["A","B"] then
        return;
    fi;

    z:=cat("A
            B");    
end proc;

mint t.mpl gives

on line     7:     z:=cat("A
                          ^ Syntax error
A "then" was found without a previous matching "if".
An "end" may be needed to close the "in" construct from line 3.

But these two below procs below it gives no syntax error

foo:= proc(x)
local z := "";
    if not x in ["A","B"] then
        return;
    fi;  
end proc;

And

foo:= proc(x)
local z := "";
    z:=cat("A
            B");    
end proc;

No syntax error on either one. the syntax error only shows up when combining them. 

What does if not x in ["A","B"] then  have to do with the cat  below it? And why when they are combined, the syntax error shows?

I know of workaround, such as changing the cat to  z:=cat("A\nB");     or keep the strings on two lines, but do it like this

    z:=cat("A\n
           B");

Or write it like this

   z:=cat("A "
           "B"); 

But none of these changes were needed before adding the not x in ["A","B"]  before.

Is this a bug in mint? Is there a work around so the first example above still works using 

    z:=cat("A
            B");   

?

The purpose of this document is:

a) to correct the physics that was used in the document "Minimal Road Radius for Highway Superelevation" recently submitted to the Maple Applications Center;

b) to confirm the values found in the manual for the American Association of State Highway and Transportation Officials (AASHTO) that engineers use to design and build these banked curves are physically sound. 

c) to highlight the pedagogical value inherent in the Maple language to distinguish between assignment ( := )  and equivalence (  =  );

d) but most importantly, to demonstrate the pedagogical value Maple has in thinking about solving a problem involving a physical process. Given Maple's symbolic mathematics capabilities, one can implement a top-down approach to the physics and the mathematics, working from the general principle to the specific example. This allows one to avoid the types of errors that occur when translating the problem into a bottom up approach, from specific values of the example to the general principle, an approach that is required by most other computational systems.

I hope that others are willing to continue to engage in discussions related to the pedagogical value of Maple beyond mathematics.

I was asked to post this document to both here and the Maple Applications Center

[Document edited for typos.]

Minimum_Road_Radius.mw

Let say the procedure MyProc returns two variables as

A,B:= MyProc(…);

However, for programming purpose, I do not want to create an unused variable. Assuming one only needs B, not A, is there a way not to create and assign A?

For information, in Matlab, it is a commonly used technique. The syntax is

[~,B]= MyProc(…);

In Maple, the meaning of ~ is different, but I am looking for something similar.

 

 Today I read the  Problem 5.21 from book Maple and Mathematica, A Problem Solving Approach for Mathematics:

The book uses following codes:

with(LinearAlgebra): n:=9; v:=Vector(n); T:=v->add(v[i]*x^(i-1),i=1..n); P:=Vector(n,symbol=p); Q:=Vector(n,symbol=q); Z1:=T(a*P+b*Q); Z2:=a*T(P)+b*T(Q);
expand(T(a*P+b*Q)-(a*T(P)+b*T(Q)));
evalb(expand(Z1)=expand(Z2));

But I think  these codes just verify rather than prove(n is always specific number). This example is not difficult to prove by hand. but I'd like to know Maple how to prove it. It seems not easy.

 

 

 

 

 

 

 

 

 

 

 

I want to solve the following IBVP:

However, the answer given by pdsolve doesn't give  with pdetest.


 

restart

eq := diff(u(x, t), t)-k*(diff(u(x, t), x, x)) = 0

diff(u(x, t), t)-k*(diff(diff(u(x, t), x), x)) = 0

(1)

ic := u(x, 0) = 0

u(x, 0) = 0

(2)

bc := u(0, t) = p(t)

u(0, t) = p(t)

(3)

sol := `assuming`([simplify(pdsolve([eq, ic, bc]))], [k > 0, x > 0, t > 0])

u(x, t) = (1/2)*x*(Int(p(zeta)*exp(-(1/4)*x^2/(k*(t-zeta)))/(t-zeta)^(3/2), zeta = 0 .. t))/(Pi^(1/2)*k^(1/2))

(4)

`assuming`([simplify(pdetest(sol, [eq, ic, bc]))], [k > 0, t > 0, x > 0])

[(1/2)*x*(-t*(Int(p(zeta)*exp(-(1/4)*x^2/(k*(t-zeta)))/(t-zeta)^(7/2), zeta = 0 .. t))+limit(p(zeta)*exp(-(1/4)*x^2/(k*(t-zeta)))/(t-zeta)^(3/2), zeta = t)+Int(p(zeta)*exp(-(1/4)*x^2/(k*(t-zeta)))*zeta/(t-zeta)^(7/2), zeta = 0 .. t)+Int(p(zeta)*exp(-(1/4)*x^2/(k*(t-zeta)))/(t-zeta)^(5/2), zeta = 0 .. t))/(Pi^(1/2)*k^(1/2)), 0, -p(t)]

(5)

``

Download IBVP.mw

Please everybody, help me to make phaseportrait 3D

Maple's pdsolve() is quite capable of solving the PDE that describes the motion of a single-span Euler beam.  As far as I have been able to ascertain, there is no obvious way of applying pdsolve() to solve multi-span beams.  The worksheet attached to this post provides tools for solving multi-span Euler beams.  Shown below are a few demos.  The worksheet contains more demos.

 

A module for solving the Euler beam with the method of lines

beamsolve

 

The beamsolve proc solves a (possibly multi-span) Euler beam equation:``

"rho ((&PartialD;)^2u)/((&PartialD;)^( )t^2)+ ((&PartialD;)^2)/((&PartialD;)^( )x^2)(EI ((&PartialD;)^(2)u)/((&PartialD;)^( )x^(2)))=f"

subject to initial and boundary conditions.  The solution u = u(x, t) is the

transverse deflection of the beam at point x at time t, subject to the load
density (i.e., load per unit length) given by f = f(x, t). The coefficient rho 

is the beam's mass density (mass per unit length), E is the Young's modulus of

the beam's material, and I is the beam's cross-sectional moment of inertia

about the neutral axis.  The figure below illustrates a 3-span beam (drawn in green)
supported on four supports, and loaded by a variable density load (drawn in gray)
which may vary in time.  The objective is to determine the deformed shape of the
beam as a function of time.


The number of spans, their lengths, and the nature of the supports may be specified

as arguments to beamsolve.

 

In this worksheet we assume that rho, E, I are constants for simplicity. Since only
the product of the coefficients E and I enters the calculations, we lump the two

together into a single variable which we indicate with the two-letter symbol EI.

Commonly, EI is referred to as the beam's rigidity.

 

The PDE needs to be supplied with boundary conditions, two at each end, each

condition prescribing a value (possibly time-dependent) for one of u, u__x, u__xx, u__xxx 
(that's 36 possible combinations!) where I have used subscripts to indicate

derivatives.  Thus, for a single-span beam of length L, the following is an admissible

set of boundary conditions:
u(0, t) = 0, u__xx(0, t) = 0, u__xx(L, t) = 0, u__xxx(t) = sin*t.   (Oops, coorection, that last
condition was meant to be uxxx(L,t) = sin t.)

Additionally, the PDE needs to be supplied with initial conditions which express

the initial displacement and the initial velocity:
"u(x,0)=phi(x),   `u__t`(x,0)=psi(x)."

 

The PDE is solved through the Method of Lines.  Thus, each span is subdivided into

subintervals and the PDE's spatial derivatives are approximated through finite differences.

The time derivatives, however, are not discretized.  This reduces the PDE into a set of

ODEs which are solved with Maple's dsolve().  

 

Calling sequence:

        beamsolve(L, n, options)

 

Parameters:

        L:  List of span lengths, in order from left to right, as in [L__1, L__2 .. (), `L__&nu;`].

        n The number of subintervals in the shortest span (for the finite difference approximation)

 

Notes:

• 

It is assumed that the spans are laid back-to-back along the x axis, with the left end
of the overall beam at x = 0.

• 

The interior supports, that is, those supports where any two spans meet, are assumed
to be of the so-called simple type.  A simple support is immobile and it doesn't exert
a bending moment on the beam.  Supports at the far left and far right of the beam can
be of general type; see the BC_left and BC_right options below.

• 

If the beam consists of a single span, then the argument L may be entered as a number
rather than as a list. That is, L__1 is equivalent to [L__1].

 

Options:

        All options are of the form option_name=value, and have built-in default values.

        Only options that are other than the defaults need be specified.

 

        rho: the beam's (constant) mass density per unit length (default: rho = 1)

        EI: the beam's (constant) rigidity (default: EI = 1)

        T: solve the PDE over the time interval 0 < t and t < T (default: T = 1)

        F: an expression in x and t that describes the applied force f(x, t)  (default: F = 0)
        IC: the list [u(x, 0), u__t(x, 0)]of the initial displacement and velocity,  as
                expressions in x (default: IC = [0,0])

        BC_left: a list consisting of a pair of boundary conditions at the left end of
                the overall (possibly multi-span beam.  These can be any two of
                u = alpha(t), u_x = beta(t), u_xx = gamma(t), u_xxx = delta(t). The right-hand sides of these equations

                can be any expression in t.  The left-hand sides should be entered literally as indicated.

                If a right-hand side is omitted, it is taken to be zero.   (default: BC_left = [u, u_xx] which

                corresponds to a simple support).

        BC_right: like BC_left, but for the right end of the overall beam (default: BC_right = "[u,u_xx])"

 

The returned module:

        A call to beamsolve returns a module which presents three methods.  The methods are:

 

        plot (t, refine=val, options)

                plots the solution u(x, t) at time t.  If the discretization in the x direction

                is too coarse and the graph looks non-smooth, the refine option

                (default: refine=1) may be specified to smooth out the graph by introducing

                val number of intermediate points within each discretized subinterval.

                All other options are assumed to be plot options and are passed to plots:-display.

 

        plot3d (m=val, options)

                plots the surface u(x, t).  The optional m = val specification requests

                a grid consisting of val subintervals in the time direction (default: "m=25)"

                Note that this grid is for plotting purposes only; the solution is computed

                as a continuous (not discrete) function of time. All other options are assumed

                to be plot3d options and are passed to plots:-display.

 

        animate (frames=val, refine=val, options)

                produces an animation of the beam's motion.  The frames option (default = 50)

                specifies the number of animation frames.  The refine option is passed to plot
                (see the description above. All other options are assumed to be plot options and
                are passed to plots:-display.

Note:

        In specifying the boundary conditions, the following reminder can be helpful.  If the beam

        is considered to be horizontal, then u is the vertical displacement, `u__x ` is the slope,  EI*u__xx

        is the bending moment, and EI*u__xxx is the transverse shear force.

 

A single-span simply-supported beam with initial velocity

 

The function u(x, t) = sin(Pi*x)*sin(Pi^2*t) is an exact solution of a simply supported beam with

"u(x,0)=0,   `u__t`(x,0)=Pi^(2)sin(Pi x)."  The solution is periodic in time with period 2/Pi.

sol := beamsolve(1, 25, 'T'=2/Pi, 'IC'=[0, Pi^2*sin(Pi*x)]):
sol:-animate(size=[600,250]);

The initial condition u(x, 0) = 0, u__t(x, 0) = 1  does not lead to a separable form, and

therefore the motion is more complex.

sol := beamsolve(1, 25, 'T'=2/Pi, 'IC'=[0, 1]):
sol:-animate(frames=200, size=[600,250]);


 

A single-span cantilever beam

 

A cantilever beam with initial condition "u(x,0)=g(x),  `u__t`(x,0)=0," where g(x) is the
first eigenmode of its free vibration (calculated in another spreadsheet).  The motion is
periodic in time, with period "1.787018777."

g := 0.5*cos(1.875104069*x) - 0.5*cosh(1.875104069*x) - 0.3670477570*sin(1.875104069*x) + 0.3670477570*sinh(1.875104069*x):
sol := beamsolve(1, 25, 'T'=1.787018777, 'BC_left'=[u,u_x], 'BC_right'=[u_xx,u_xxx], 'IC'=[g, 0]):
sol:-animate(size=[600,250]);

If the initial condition is not an eigenmode, then the solution is rather chaotic.

sol := beamsolve(1, 25, 'T'=3.57, 'BC_left'=[u,u_x], 'BC_right'=[u_xx,u_xxx], 'IC'=[-x^2, 0]):
sol:-animate(size=[600,250], frames=100);


 

A single-span cantilever beam with a weight hanging from its free end

 

sol := beamsolve(1, 25, 'T'=3.57, 'BC_left'=[u,u_x], 'BC_right'=[u_xx,u_xxx=1]):
sol:-animate(size=[600,250], frames=100);


 

A single-span cantilever beam with oscillating support

 

sol := beamsolve(1, 25, 'T'=Pi, 'BC_left'=[u=0.1*sin(10*t),u_x], 'BC_right'=[u_xx,u_xxx]):
sol:-animate(size=[600,250], frames=100);


 

A dual-span simply-supported beam with moving load

 

Load moves across a dual-span beam.

The beam continues oscillating after the load leaves.

d := 0.4:  T := 4:  nframes := 100:
myload := - max(0, -6*(x - t)*(d + x - t)/d^3):
sol := beamsolve([1,1], 20, 'T'=T, 'F'=myload):
sol:-animate(frames=nframes):
plots:-animate(plot, [2e-3*myload(x,t), x=0..2, thickness=1, filled=[color="Green"]], t=0..T, frames=nframes):
plots:-display([%%,%], size=[600,250]);


 

A triple-span simply-supported beam with moving load

 

Load moves across a triple-span beam.

The beam continues oscillating after the load leaves.

d := 0.4:  T := 6: nframes := 100:
myload := - max(0, -6*(x - t)*(d + x - t)/d^3):
sol := beamsolve([1,1,1], 20, 'T'=T, 'F'=myload):
sol:-plot3d(m=50);
sol:-animate(frames=nframes):
plots:-animate(plot, [2e-3*myload(x,t), x=0..3, thickness=1, filled=[color="Green"]], t=0..T, frames=nframes):
plots:-display([%%,%], size=[600,250]);

z3d;


 

A triple-span beam, moving load falling off the cantilever end

 

In this demo the load move across a multi-span beam with a cantilever section at the right.

As it skips past the cantilever end, the beam snaps back violently.

d := 0.4:  T := 8: nframes := 200:
myload := - max(0, -6*(x - t/2)*(d + x - t/2)/d^3):
sol := beamsolve([1,1,1/2], 10, 'T'=T, 'F'=myload, BC_right=[u_xx, u_xxx]):
sol:-animate(frames=nframes):
plots:-animate(plot, [1e-2*myload(x,t), x=0..3, thickness=1, filled=[color="Green"]], t=0..T, frames=nframes):
plots:-display([%%,%], size=[600,250]);


 


Download worksheet: euler-beam-with-method-of-lines.mw

 

The uploaded worksheet contains a contourplot whose display I can't understand. Can you explain it?

Countourplot.mw

From Wikipedia,

However, when I plug the formula of u(x, t) into Maple, it doesn't seem to satisfy the PDE and is stuck evaluating.
 

restart

eq := diff(u(x, t), t)-k*(diff(u(x, t), x, x)) = f(x, t)

diff(u(x, t), t)-k*(diff(diff(u(x, t), x), x)) = f(x, t)

(1)

ic := u(x, 0) = 0

u(x, 0) = 0

(2)

"G(x,t):=1/(sqrt(4*pi*k*t))exp(-(x^(2))/(4*k*t))"

proc (x, t) options operator, arrow, function_assign; exp(-(1/4)*x^2/(k*t))/sqrt(4*pi*k*t) end proc

(3)

ans := u(x, t) = int(G(x-y, t-s)*f(y, s), y = -infinity .. infinity, s = 0 .. t)

u(x, t) = (1/2)*(int((int(exp(-(1/4)*(x-y)^2/(k*(t-s)))*f(y, s), y = -infinity .. infinity))/(pi*k*(t-s))^(1/2), s = 0 .. t))

(4)

`assuming`([simplify(pdetest(ans, [eq, ic]))], [t > 0])

``


 

Download InhomoHeat.mw

The uploaded worksheet contains two examples of the use of VectorCalculus[VectorSpace]. The first example seems explicable but the second does not.

I have tried and failed to find a full, clear explanation of how a vector describing a simple vector, spacecurve, or surface in the default vector space is transformed to appear in a user defined vector space.

Can anyone direct me to such an explanation, so that I can understand Maple's processing within the uploaded worksheet and enable me to use this Maple feature to future advantage?

VectorSpaceTest.mw

Hello again,

 

I have two functions f and h, that I want to show by pointplot as a diagramm (with a range from -10 to +10).

I know how to do it with "normal" functions, but what if for example the function f has 2 variables but h only has one?

f:= (sin(sqrt(x^2+y^2)))/(sqrt(x^2+y^2));

h:= f(x, 1.8);

These are the two functions.

 

So far I've made a list for each function for x  = -10 to x = 10

ListF:= [seq(f, x = -10..10, 1)];

ListH:= [seq(h, x = -10..10, 1)];

 

But I don't know how to go from there. Can I already use pointplot to connect the two lists? Or do I have to connect these two lists as one (which is what I originally planned) But I don't know how to do that, without always copying the results of one and then the other and putting both in a new list.

e.g Both lists show the values for the function for x = -10..10. If the first value of ListF is 5 and the first value of ListH is 1, then connecting both in a new list ListFH: = [[5,1]...], followed by the 9 other values.)

(5 and 1 aren't the actual results, I just used them for simplification.)

(Even if this isn't the right beginning for the solution of my original problem, I still want to know if it's even possible to take all values of one list of a function 'a' and all values of a second list of function 'b' and put them in a new list 'c' with c: = [a,b] without manually putting them together. So that the first value of list a is paired with the first of list b, the second of list a with the second of list b, etc... I hope you know what I mean)

In regards to my original problem I thought I could do something like this:

pointplot( [ [ListF], [ListH] ]);

 

I'm grateful for every answer :)

 

 

 

 

 

 

 

When making a function and using the return type, I found Maple is not catching the case when the function returns wrong type.

Actually there are two issues in this example I like to ask about. First, here is the example

restart;
kernelopts(assertlevel):=2;
TypeTools:-AddType(type_A, record(x::integer)):

foo:=proc( A::type_A ) ::type_A;  #this is what return type should be
     print( type(A,'type_A')); #this prints TRUE
     A:-x :=1.5; #opps, wrong type, changes type of record now!
     print( type(A,'type_A')); #This now prints FALSE
     return A;
end proc:

A:=Record('x' = 1);
B:=foo(A):
eval(B)

The call to foo() goes through as expected since type is correct.

First issue: Inside the function doing A:-x :=1.5;  changed the type of record now, since is supposed to be integer and now become real. Is there a way to have Maple detect this at run time?

Second issue: The function was defined to return type_A  but due to this overwriting the field of the record by wrong value, it is no longer type_A  (the print now says false). But why Maple did not detect this? Since the function is defined to only return type_A ?

Is it possible to change the code above to catch these type mistakes I made?

First 48 49 50 51 52 53 54 Page 50 of 56