## Table / table width...

Is there any possibility to modify column width within tables, so that they become equal?

## Problem in evaluating 2D improper integral ...

Dear Users!

I want to evaluate following integral (f[i]'s) for different values of rho as shown. But find some problem and can't find f[3], f[4], f[5] and f[6]. If the integral from direct way is hard to calculate please guide me how I can evaluate it using numerical integration?

restart; HAM := [1, 2, 3, 4, 5, 6]; U := y^6*sin(x); alpha := 1/3;

for i while i <= nops(HAM) do

rho := op(i, HAM);

f[i] := int(int(U/((x^rho-p^rho)^alpha*(y^rho-q^rho)^alpha), q = 0 .. y), p = 0 .. x)

end do

Special request to @acer @Carl Love @Kitonum @Preben Alsholm

## How to fasten this simulation?...

Hi,

I want to simulate a decision rule (let's say a production control strategy to fix the ideas) based on the outcomes of a binomial random variable.

One stage of this simulation involves operations which correspond to the NaiveProc described below. This procedure is a straightforward and rather naive translation in Maple of these operations.
It is given here to help you to understand what is to be done.

This coding being extremely slow, I implemented the required operations differently.
Given the fact that I'm only concerned by binomial samplings with outcomes 0 and 1, I basically replaced these samplings by three operations  U:=... , Got01:=... , Got0:= ... .
Each new implementation is about 200 times faster than the naive one.

My question is: Can we do still better?
For information the same simulation realized with R runs in less than 15s when REP = 10^8 (more than 100 times faster than what I'm capable to do with Maple)

 > restart:
 > with(Statistics):
 > # This is the naive coding of the problem # # It has the advantage to explain clearly (at least I hope so) what is to be done. NaiveProc := proc(REP, a, b, N)   local roll, rep, p, K, N0, N1:   roll := rand(a .. b);   N0   := 0:   N1   := 0:   for rep from 1 to REP do     p := roll();     K := Sample(Binomial(N, p), 1)[1]:     if K=0 then       N0 := N0+1:     elif K=1 then       N1 := N1+1:     end if:   end do:   N0, N1: end proc:      CodeTools:-Usage(NaiveProc(10^3, 0, 5e-4, 25000));
 memory used=78.92MiB, alloc change=68.00MiB, cpu time=1.21s, real time=6.30s, gc time=24.80ms
 (1)
 > # As the previous code is very slow I implemented several variants based on the fact # that I care only on values of K equal to 0 and 1 and that it is then useless to sample # a Binomial random variable to do this. # # Each of them is much faster than the naive coding... but can we even faster? # For comparison, the same simulation realized in R takes less than 15s to run with REP=10^8 pi := (n, p, k) -> binomial(n, k) * (1-p)^(n-k) * p^k; f1 := proc(REP, a, b, N)   local Q, P0, P1, P01, U, Got01, Got0, N01, N0, N1:   Q     := Sample(Uniform(a, b), REP)^+:   P0    := pi~(N, Q, 0):   P1    := pi~(N, Q, 1):   P01   := P0 + P1:   U     := Sample(Uniform(0, 1), REP)^+:   Got01 := Select(t -> is(t <= 0), U-P01):   Got0  := Select(t -> is(t <= 0), U-P0 );   N01   := numelems(Got01):   N0    := numelems(Got0):   N1    := N01-N0:   N0, N1; end proc: CodeTools:-Usage(f1(10^5, 0, 5e-4, 25000)); print(): f2 := proc(REP, a, b, N)   local Q, P0, P1, P01, U, Got01, Got0, N01, N0, N1:   Q     := Sample(Uniform(a, b), REP)^+:   P0    := pi~(N, Q, 0):   P1    := pi~(N, Q, 1):   P01   := P0 + P1:   U     := Sample(Uniform(0, 1), REP)^+:   Got01 := select[flatten](<=, U-P01, 0):   Got0  := select[flatten](<=, U-P0 , 0):   N01   := numelems(Got01):   N0    := numelems(Got0):   N1    := N01-N0:   N0, N1; end proc: CodeTools:-Usage(f2(10^5, 0, 5e-4, 25000)); print(): f3 := proc(REP, a, b, N)   local Q, P0, P1, P01, U, Got01, Got0, N01, N0, N1:   Q     := Sample(Uniform(a, b), REP)^+:   P0    := pi~(N, Q, 0):   P1    := pi~(N, Q, 1):   P01   := P0 + P1:   U     := Sample(Uniform(0, 1), REP)^+:   Got01 := Vector(REP, i -> if(U[i] <= P01[i], 1, 0)):   Got0  := Vector(REP, i -> if(U[i] <= P0 [i], 1, 0)):   N01   := add(Got01):   N0    := add(Got0):   N1    := N01-N0:   N0, N1; end proc: CodeTools:-Usage(f3(10^5, 0, 5e-4, 25000));
 memory used=376.83MiB, alloc change=296.77MiB, cpu time=4.12s, real time=4.03s, gc time=430.38ms
 memory used=173.26MiB, alloc change=0 bytes, cpu time=2.30s, real time=1.98s, gc time=461.22ms
 memory used=154.19MiB, alloc change=0 bytes, cpu time=2.28s, real time=2.01s, gc time=432.40ms
 (2)
 >
 >

## improvement to Latex. Removing extra \\ at end of ...

When Maple converts a matrix or a vector to Latex it uses latex array, which  is fine, but what it does is insert an exatra \\ at the end of the last row, just before the \end{array}

This causes problem for some software which reads the latex file. It causes the software to take this as empty row and inserts a blank row at the end.

Here is a small example

A:=Matrix([[1,2],[3,4]]);
Physics:-Latex(A);

\left[\begin{array}{cc}1 & 2 \\3 & 4 \\\end{array}\right]

Notice the extra \\  just before the \end{array} In Latex, this tells latex compiler to insert newline basically.

When opening the latex file using external software, which reads Latex and converts it to GUI, it show this

And now I have to go edit the latex by hand removing the extra \\ (inside the editor I can do global search and replace)

A better outout from Maple's Latex command would be the following

\left[\begin{array}{cc}1 & 2 \\3 & 4 \end{array}\right]

Even though both are valid Latex, the above is better.  I was wondering how hard it is to do this change.

All what the conversion needs to do is just check if the row in the matrix (or Vector) is the last one, and omit the extra \\ at the end of the last row. That is all.

I could ofcourse write code to try to parse this each time I call Latex and to remove \\ myself in the program, but it will be much easier if Maple automatically did this.

ps. if the Latex conversion source code could be made public, others could help make improvement to it for free, benefiting Maple and everyone using it. Maplesoft would still approve the changes before checkin, and retain the copy right of the source code ofcourse.

Maple 2020.1

## How to "remove output from worksheet" while it is ...

One of the known issues with Maple GUI (written in Java) is that it is slow.

When I run a long script, which prints few lines to the screen for each step (to help tell where it is during a long run), and if there are 20,000 steps to run which takes 2 days to finish), then the worksheet and I think all of Maple seem to slow down. May be due to GUI trying to flush output to worksheet which now has lots of output.

I noticed when I terminate the loop in the middle and then clear the worksheet from the output and start it again from where it stopped, then it runs/scrolls much faster initially untill the worksheet starts to fill up.

The problem is that one can no longer do Evaluate->Remove output from worksheet as worksheet is busy. This option becomes grayed out.

Is there a trick to bypass this limitation? It will be really nice to be able to clear output from worksheet while it is running.  I do not understand why a user can not do this now even if worksheet is running. In Mathematica for example, this is possible to clear the output while notebook is busy running. Not in Maple.

ps. I want to try to change my program to print output to external file instead to the worksheet and then can monitor the output progress using that file outside of Maple to see if this helps with performance.

This is until Maplesoft adds support to allow one to clear worksheet while it is busy.

Using Maple 2020.1 on windows. Using worksheet mode, not document mode.

## Multiply Quaternions...

Hello again,   I'm trying to write a procedure to multiply quaternions.   We know that they can be represented as a vector of length 4.   See Wikipedia.   My try  -

qaa=[8,4,6,2] and qab =[2,,4,6,8]
mult:=proc(a,b)

end proc;

maybe needs some looping or data from a table.

Regards,

Matt

## Margins in a Bode plot...

Hello All, is there a command/instruction that can tell me the phase margin, gain margin automatically after I have a bode plot, please?

## Units Standard / compare values with zero...

Units are a neverending story, here's a variant of a problem raised before.

How can i get the minimum of 2 values with Units[Standard] loaded, when one of them could be zero (this loosing its units)?

• https://www.mapleprimes.com/questions/229640-Units-Disappearing
• https://www.mapleprimes.com/questions/230165-Error-in-UnitsTestDimensions-Invalid
• https://www.mapleprimes.com/questions/230064-Compare-Similar-Units

 (1)

 (2)

 (3)

 (4)

 >
 >
 (1)
 >
 (2)
 >
 (3)
 >
 (4)
 >
 >

## How to write Explore command ?...

I want to vary t from -15 to -7 and from 7 to 15 how to write the Explore command?
example : Explore(Fig(t), t=-15..-7 and t=7..15); which does't work.  Thank you.

## How do I solve this using Maple? Integrals - sphe...

The center of mass for the density function p(r,θ,φ) = ln(r^2 + θ^2 + φ^2 +1) over the solid sphere radius 2.

I'm not sure how to do this on Maple.

Many thanks!

## A little about controlled platforms (parallel...

by: Maple 17

Controlled platform with 6 degrees of freedom. It has three rotary-inclined racks of variable length:

and an example of movement parallel to the base:

Perhaps the Stewart platform may not reproduce such trajectories, but that is not the point. There is a way to select a design for those specific functions that our platform will perform. That is, first we consider the required trajectories of the platform movement, and only then we select a driving device that can reproduce them. For example, we can fix the extreme positions of the actuators during the movement of the platform and compare them with the capabilities of existing designs, or simulate your own devices.
In this case, the program consists of three parts. (The text of the program directly for the first figure : PLATFORM_6.mw) In the first part, we select the starting point for the movement of a rigid body with six degrees of freedom. Here three equations f6, f7, f8 are responsible for the six degrees of freedom. The equations f1, f2, f3, f4, f5 define a trajectory of motion of a rigid body. The coordinates of the starting point are transmitted via disk E for the second part of the program. In the second part of the program, the trajectory of a rigid body is calculated using the Draghilev method. Then the trajectory data is transferred via the disk E for the third part of the program.
In the third part of the program, the visualization is executed and the platform motion drive device is modeled.
It is like a sketch of a possible way to create controlled platforms with six degrees of freedom. Any device that can provide the desired trajectory can be inserted into the third part. At the same time, it is obvious that the geometric parameters of the movement of this device with the control of possible emergency positions and the solution of the inverse kinematics problem can be obtained automatically if we add the appropriate code to the program text.
Equations can be of any kind and can be combined with each other, and they must be continuously differentiable. But first, the equations must be reduced to uniform variables in order to apply the Draghilev method.
(These examples use implicit equations for the coordinates of the vertices of the triangle.)

## Logaritmic curve to determine Eigenvalues...

Hello friends

I am a PhD student at the University of Miskolc (Hungary). I am writing to asking for help.

considering that my matrix is correct (based on Article 1) and I have all the values needed:

-  From Article 2, How can I plot the graph of Figure 2 and Figure 3 in a logarithmic scale (X-axis) and linear scale (Y-axis). Also, how can I plot the mode shapes of Figure 7 and Figure 8?

I tried to do it (below) but I am not sure it is correct.

Graphs_Article_2.mw

Reference:
Article 1 - Doyle, Paul F., and Milija N. Pavlovic. "Vibration of beams on partial elastic foundations." Earthquake Engineering & Structural Dynamics 10, no. 5 (1982): 663-674.

Article 2 - Cazzani, Antonio. "On the dynamics of a beam partially supported by an elastic foundation: an exact solution-set." International Journal of structural stability and dynamics 13, no. 08 (2013): 1350045.

## How to generate a matrix given a certain lenght an...

Hi friends!

I have the following problem.

I'm trying to generate a matrix given a certain lenght n and a polynomial g(x) of degree r as follows:

If n=10, g(x)=x^4+3x^3+x^2+2x+1 and r=degree(g(x))=4, then the resulting matrix will be

i.e. a matrix with 10 columns, n-r=6 lines, and whose inputs are the coefficients of the polynomial, as follows:

Any help will be very appreciated.

Thank you!

## What to take care of when entering a tetrad

by: Maple 2020

In the study of the Gödel spacetime model, a tetrad was suggested in the literature [1]. Alas, upon entering the tetrad in question, Maple's Tetrad's package complained that that matrix was not a tetrad! What went wrong? After an exchange with Edgardo S. Cheb-Terrab, Edgardo provided us with awfully useful comments regarding the use of the package and suggested that the problem together with its solution be presented in a post, as others may find it of some use for their work as well.

The Gödel spacetime solution to Einsten's equations is as follows.

 >
 (1)
 >
 (2)

Working with Cartesian coordinates,

 >
 (3)

the Gödel line element is

 >
 (4)

Setting the metric

 >
 (5)

The problem appeared upon entering the matrix M below supposedly representing the alleged tetrad.

 >
 >
 (6)

Each of the rows of this matrix is supposed to be one of the null vectors . Before setting this alleged tetrad, Maple was asked to settle the nature of it, and the answer was that M was not a tetrad! With the Physics Updates v.857, a more detailed message was issued:

 >
 (7)

So there were actually three problems:

 1 The entered entity was a null tetrad, while the default of the Physics package is an orthonormal tetrad. This can be seen in the form of the tetrad metric, or using the library commands:
 >
 (8)
 >
 (9)
 >
 (10)
 2 The matrix M would only be a tetrad if the spacetime index is contravariant. On the other hand, the command IsTetrad will return true only when M represents a tetrad with both indices covariant. For  instance, if the command IsTetrad  is issued about the tetrad automatically computed by Maple, but is passed the matrix corresponding to   with the spacetime index contravariant,  false is returned:
 >
 (11)
 >
 (12)
 3 The matrix M corresponds to a tetrad with different signature, (+---), instead of Maple's default (---+). Although these two signatures represent the same physics, they differ in the ordering of rows and columns: the timelike component is respectively in positions 1 and 4.

The issue, then, became how to correct the matrix M to be a valid tetrad: either change the setup, or change the matrix M. Below the two courses of action are provided.

First the simplest: change the settings. According to the message (7), setting the tetrad to be null, changing the signature to be (+---) and indicating that M represents a tetrad with its spacetime index contravariant would suffice:

 >
 (13)

The null tetrad metric is now as in the reference used.

 >
 (14)

Checking now with the spacetime index contravariant

 >
 (15)

At this point, the command IsTetrad  provided with the equation (15), where the left-hand side has the information that the spacetime index is contravariant

 >
 (16)

Great! one can now set the tetrad M exactly as entered, without changing anything else. In the next line it will only be necessary to indicate that the spacetime index, , is contravariant.

 >
 (17)

The tetrad is now the matrix M. In addition to checking this tetrad making use of the IsTetrad command, it is also possible to check the definitions of tetrads and null vectors using TensorArray.

 >
 (18)
 >
 (19)

For the null vectors:

 >
 (20)
 >
 (21)

From its Weyl scalars, this tetrad is already in the canonical form for a spacetime of Petrov type "D": only

 >
 (22)
 >
 (23)

Attempting to transform it into canonicalform returns the tetrad (17) itself

 >
 (24)

Let's now obtain the correct tetrad without changing the signature as done in (13).

Start by changing the signature back to

 >
 (25)

So again, M is not a tetrad, even if the spacetime index is specified as contravariant.

 >
 (26)

By construction, the tetrad M has its rows formed by the null vectors with the ordering . To understand what needs to be changed in M, define those vectors, independent of the null vectors  (with underscore) that come with the Tetrads package.

 >

and set their components using the matrix M taking into account that its spacetime index is contravariant, and equating the rows of M  using the ordering :

 >
 (27)
 >
 (28)

Check the covariant components of these vectors towards comparing them with the lines of the Maple's tetrad

 >
 (29)

This shows the  null vectors (with underscore) that come with Tetrads package

 >
 (30)

So (29) computed from M is the same as (30) computed from Maple's tetrad.

But, from (30) and the form of Maple's tetrad

 >
 (31)

for the current signature

 >
 (32)

we see the ordering of the null vectors is , not  used in [1] with the signature (+ - - -). So the adjustment required in  M, resulting in , consists of reordering M's rows to be

 >
 (33)
 >
 (34)

Comparing  with the tetrad computed by Maple ((24) and (31), they are actually the same.

References

[1]. Rainer Burghardt, "Constructing the Godel Universe", the arxiv gr-qc/0106070 2001.

[2]. Frank Grave and Michael Buser, "Visiting the Gödel Universe",  IEEE Trans Vis Comput GRAPH, 14(6):1563-70, 2008.