Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

Dear All,

I am actively using Maple for scientific research but I am obliged to use xkill several times a day (~70 times) and restart Maple again since the software freezes and completely stops after a few minutes. I was wondering whether this is an issue with the present verison (Maple 15) and that upgrading to a latest version is inevitable. Your help is highly appreciated.

 

Thank you

Fede

What i am trying to achieve is to evaluate the sequence as, shown, but from within a try-catch statement that handles and keeps a tally on the number and arguements for which the sequence encounters a division by zero error. ie, instead of haulting evaluation when each error is encountered, i want my code to record the index values at which the error occured, then continue on to the next term.
 

restart

with(Statistics):

``

F := (-2*n[1]*n[3]-4*n[2]*n[1]*n[3]+4*n[2]*n[3]+4*n[3]*n[4]*n[1]+n[1])/(-n[1]-2*n[2]*n[1]+2*n[2]+2*n[4]*n[1]):

S := proc (N, M, G, L) options operator, arrow; [seq(seq(seq(seq(F, n[1] = N .. N), n[2] = M .. M), n[3] = G .. G), n[4] = L .. L)] end proc

proc (N, M, G, L) options operator, arrow; [seq(seq(seq(seq(F, n[1] = N .. N), n[2] = M .. M), n[3] = G .. G), n[4] = L .. L)] end proc

(1)

A := {}; -1; U := 0; -1; K := 0; -1; E := 0

0

(2)

J := 0:

H := 1

1

(3)

K[1] := J+H:

try S(K[1], K[2], K[3], K[4]) catch "numeric exception: division by zero": E := E+1; `union`({[K[1], K[2], K[3], K[4]]}, A) end try

[-1]

(4)

J := 0:

H := 1

1

(5)

K[1] := J:

try S(K[1], K[2], K[3], K[4]) catch "numeric exception: division by zero": E := E+1; `union`({[K[1], K[2], K[3], K[4]]}, A) end try

[0]

(6)

J := 0:

H := 1

1

(7)

K[1] := J:

try S(K[1], K[2], K[3], K[4]) catch "numeric exception: division by zero": E := E+1; `union`({[K[1], K[2], K[3], K[4]]}, A) end try

1

 

{[0, 0, 1, 0]}

(8)

J := 0:

H := 1

1

(9)

K[1] := J:

try S(K[1], K[2], K[3], K[4]) catch "numeric exception: division by zero": E := E+1; `union`({[K[1], K[2], K[3], K[4]]}, A) end try

2

 

{[0, 0, 0, 1]}

(10)

``


 

Download PLEASE_HELP_MAPLE.mw

Hi

I have a long column vector containing data in Records.

A:=Vector[column](4, [J_K = `Record(mu = 724.901557888305, sigma = 96.7437910529146)`, I_W = `Record(mu = 775.098442111694, sigma = 96.7437910529198)`, K_J = `Record(mu = 785.098442111694, sigma = 96.7437910529198)`, D_B = `Record(mu = 764.901557888305, sigma = 96.7437910529146)`])

How to I sort this in descending values of mu so I get:

Vector[column](4, [K_J = `Record(mu = 785.098442111694, sigma = 96.7437910529198)`,I_W = `Record(mu = 775.098442111694, sigma = 96.7437910529198)`,D_B = `Record(mu = 764.901557888305, sigma = 96.7437910529146)`,J_K = `Record(mu = 724.901557888305, sigma = 96.7437910529146)`])

Im aware you can extract mu from Records by the rhs(A[1]):-mu

 

 

Hello,
I am trying to do the following double integral in tranches as listed here:

P := proc (x, y) options operator, arrow; (1/2)*exp(-(1/2)*(x^2+G*y^2-2*B*x*y)/(-B^2+G))/(Pi*sqrt(-B^2+G)) end proc

Since G and B are constant

((int(x = 0 .. infinity))*(int(y = -infinity .. 0))+(int(x = -infinity .. 0))*(int(y = 0 .. infinity)))*P(x, y)

But does notwork. How do I pass these coordinates to polar?

Regards.

f := (z, t) -> ln(t)^2/((t^2+1)*(t-z));

int(f(z, t), t = 0 .. infinity) assuming Im(z) > 0;
       int(ln(t)^2/((t^2+1)*(t-z)), t = 0 .. infinity)

int(f(a + I*b, t), t = 0 .. infinity) assuming a::real, b > 0; # 0*infinity
       -sqrt(a^2+b^2-2*b+1)*signum(I*arctan(b, a)-I*arctan(-b, -a)-I*Pi)*
       infinity/((I*b-I+a)*(I*b+I+a))

int(f(z, t), t = 0 .. infinity) assuming Re(z) > 0, Im(z) > 0;
       int(ln(t)^2/((t^2+1)*(t-z)), t = 0 .. infinity)

int(f(a + I*b, t), t = 0 .. infinity) assuming a > 0, b > 0;
      -((3*I)*Pi^3*b+3*Pi^3*a-(16*I)*Pi^2*arctan(b/a)-(6*I)*Pi*ln(a^2+b^2)^2+(24*I)*
      Pi*arctan(b/a)^2+(6*I)*ln(a^2+b^2)^2*arctan(b/a)-(8*I)*arctan(b/a)^3-8*Pi^2*
      ln(a^2+b^2)+24*Pi*ln(a^2+b^2)*arctan(b/a)+ln(a^2+b^2)^3-12*ln(a^2+b^2)*
      arctan(b/a)^2)/(24*(-b^2+(2*I)*a*b+a^2+1))

So it looks like the first three can be made to work as well (and the result in terms of z will be much neater).

 

the Eigenvalues are showing with I and am not expecting a complex eigenvalues so what is that I stand for? Can you please help? Thank You

Hi

I've got this list:

L:=[[TC,DB], [], [TD,JK], [IW,CM], [], [KJ,DJ]]

What command to remove the 'null sets', leaving :=[[TC,DB],[TD,JK], [IW,CM], [KJ,DJ]]

this doesn't work:

remove(has, L, 0)

I've compiled a program with Maple 18. unfortunately it gives me the message "Large sortie de plus de 1000000 noeuds". If any one have any idea to resolve this problem. Thanks you very mutch for your support. 

With Startup Code Editor opened, save and close the parent worksheet. Any unsaved changes in the Code Editor are lost.

 

A project that I have been working on is adding some functionality for Cluster Analysis to Maple (a small part of a much bigger project to increase Maple’s toolkit for exploratory data mining and data analysis). The launch of the MapleCloud package manager gave me a way to share my code for the project as it evolves, providing others with some useful new tools and hopefully gathering feedback (and collaborators) along the way.

At this point, there aren’t a lot of commands in the ClusterAnalysis package, but I have already hit upon several interesting applications. For example, while working on a command for plotting clusters of points, one problem I encountered was how to draw the minimal volume enclosing ellipsoid around a group (or cluster) of points. After doing some research, I stumbled upon Khachiyan’s Algorithm, which related to solving linear programming problems with rational data. The math behind this is definitely interesting, but I’m not going to spend any time on it here. For further reading, you can explore the following:

Khachiyan’s Algorithm had previously been applied in some other languages, but to the best of my knowledge, did not have any Maple implementations. As such, the following code is an implementation of Khachiyan’s Algorithm in 2-D, which could be extended to N-dimensional space rather easily.

This routine accepts an Nx2 dataset and outputs either a plot of the minimum volume enclosing ellipsoid (MVEE) or a list of results as described in the details for the ‘output’ option below.

MVEE( X :: DataSet, optional arguments, additional arguments passed to the plotting command );

The optional arguments are as follows:

  • tolerance : realcons;  specifies the convergence criterion
  • maxiterations : posint; specifies the maximum number of iterations
  • output : {identical(data,plot),list(identical(data,plot))}; specifies the output. If output includes plot, then a plot of the enclosing ellipsoid is returned. If output includes data, then the return includes is a list containing the matrix A, which defines the ellipsoid, the center of the ellipse, and the eigenvalues and eigenvectors that can be used to find the semi-axis coordinates and the angle of rotation, alpha, for the ellipse.
  • filled : truefalse; specifies if the returned plot should be filled or not

Code:

#Minimum Volume Enclosing Ellipsoid
MVEE := proc(XY, 
              {tolerance::positive:= 1e-4}, #Convergence Criterion
              {maxiterations::posint := 100},
              {output::{identical(data,plot),list(identical(data,plot))} := data},
              {filled::truefalse := false} 
            )

    local alpha, evalues, evectors, i, l_error, ldata, ldataext, M, maxvalindex, n, ncols, nrows, p1, semiaxes, stepsize, U, U1, x, X, y;
    local A, center, l_output; #Output

    if hastype(output, 'list') then
        l_output := output;
    else
        l_output := [output];
    end if;

    kernelopts(opaquemodules=false):

    ldata := Statistics:-PreProcessData(XY, 2, 'copy');

    nrows, ncols := upperbound(ldata);
    ldataext := Matrix([ldata, Vector[column](nrows, ':-fill' = 1)], 'datatype = float');

    if ncols <> 2 then
        error "expected 2 columns of data, got %1", ncols;
    end if;

    l_error := 1;

    U := Vector[column](1..nrows, 'fill' = 1/nrows);

    ##Khachiyan Algorithm##
    for n to maxiterations while l_error >= tolerance do

        X := LinearAlgebra:-Transpose(ldataext) . LinearAlgebra:-DiagonalMatrix(U) . ldataext;
        M := LinearAlgebra:-Diagonal(ldataext . LinearAlgebra:-MatrixInverse(X) . LinearAlgebra:-Transpose(ldataext));
        maxvalindex := max[index](map['evalhf', 'inplace'](abs, M));
        stepsize := (M[maxvalindex] - ncols - 1)/((ncols + 1) * (M[maxvalindex] - 1));
        U1 := (1 - stepsize) * U;
        U1[maxvalindex] := U1[maxvalindex] + stepsize;
        l_error := LinearAlgebra:-Norm(LinearAlgebra:-DiagonalMatrix(U1 - U));
        U := U1;

    end do;

    A := (1/ncols) * LinearAlgebra:-MatrixInverse(LinearAlgebra:-Transpose(ldata) . LinearAlgebra:-DiagonalMatrix(U) . ldata - (LinearAlgebra:-Transpose(ldata) . U) . LinearAlgebra:-Transpose((LinearAlgebra:-Transpose(ldata) . U)));
    center := LinearAlgebra:-Transpose(ldata) . U;
    evalues, evectors := LinearAlgebra:-Eigenvectors(A);
    evectors := evectors(.., sort[index](1 /~ (sqrt~(Re~(evalues))), `>`, ':-output' = ':-permutation'));
    semiaxes := sort(1 /~ (sqrt~(Re~(evalues))), `>`);
    alpha := arctan(Re(evectors[2,1]) / Re(evectors[1,1]));

    if l_output = [':-data'] then
        return A, center, evectors, evalues;
    elif has( l_output, ':-plot' ) then
            x := t -> center[1] + semiaxes[1] * cos(t) * cos(alpha) - semiaxes[2] * sin(t) * sin(alpha);
            y := t -> center[2] + semiaxes[1] * cos(t) * sin(alpha) + semiaxes[2] * sin(t) * cos(alpha);
            if filled then
                p1 := plots:-display(subs(CURVES=POLYGONS, plot([x(t), y(t), t = 0..2*Pi], ':-transparency' = 0.95, _rest)));
            else
                p1 := plot([x(t), y(t), t = 0..2*Pi], _rest);
            end if;
        return p1, `if`( has(l_output, ':-data'), op([A, center, evectors, evalues]), NULL );
    end if;

end proc:

 

You can run this as follows:

M:=Matrix(10,2,rand(0..3)):

plots:-display([MVEE(M,output=plot,filled,transparency=.3),
                plots:-pointplot(M, symbol=solidcircle,symbolsize=15)],
size=[0.5,"golden"]);

 

 

As it stands, this is not an export from the “work in progress” ClusterAnalysis package – it’s actually just a local procedure used by the ClusterPlot command. However, it seemed like an interesting enough application that it deserved its own post (and potentially even some consideration for inclusion in some future more geometry-specific package). Here’s an example of how this routine is used from ClusterAnalysis:

with(ClusterAnalysis);

X := Import(FileTools:-JoinPath(["datasets/iris.csv"], base = datadir));

kmeans_results := KMeans(X[[`Sepal Length`, `Sepal Width`]],
    clusters = 3, epsilon = 1.*10^(-7), initializationmethod = Forgy);

ClusterPlot(kmeans_results, style = ellipse);

 

 

The source code for this is stored on GitHub, here:

https://github.com/dskoog/Maple-ClusterAnalysis/blob/master/src/MVEE.mm

Comments and suggestions are welcomed.

 

If you don’t have a copy of the ClusterAnalysis package, you can install it from the MapleCloud window, or by running:

PackageTools:-Install(5629844458045440);

 

I tried to solve 4 simultaneous equations but the result is an empty matrix.

Is that because there is no solution or did I make something wrong?

You can download the file by using the link below.

SimEquations.mw

hi 

I have a matrix (for example a 6*6 matrix) and I want to add a row and a column between row and column of number 3 and 4. it means that finally, we have a 7*7 matrix.

tnx

 

The documentation says that Subgroup(c) returns the subgroup of the coset c.

Also, the display of Elements(lc) is garbled in Maple as well, not just in the image.

with(GroupTheory)

sgr := Subgroup(Elements(SymmetricGroup(4)), SymmetricGroup(5))

_m917312091392

(1)

lc := LeftCoset(Perm([[1, 2]]), sgr)

_m917308956640

(2)

Subgroup(lc)

Error, invalid input: GroupTheory:-Subgroup expects its 1st argument, generators, to be of type {list, set, identical(undefined)}, but received _m917308956640

 

Elements(lc)

{_m917312836128, _m917312839712, _m917312840544, _m917312841376, _m917312842272, _m917312843296, _m917312844224, _m917312845152, _m917312846240, _m917312847072, _m917312848768, _m917312849696, _m917312850624, _m917312851552, _m917312852288, _m917312853248, _m917312854144, _m917312855072, _m917312856000, _m917312857472, _m917312858592, _m917312859552, _m917315257248, _m917315263744}

(3)

 

These worksheets provide the volume calculations  of a small causal diamond near the tip of the past light cone, using dimensional analysis and particular test metrics.

I recommend them for anyone working in causet theory on the problem of finding higher order corrections.

2D.mw

4D.mw

4Dflat.mw

 

 

 

 

I want to highlight the intersection between 2 graphs; pp(m,a) and the plane m=-0.2

PP := .8707945038*exp(-50.00000000*(m-0.842e-1)^2+(2.745342070*(m-0.842e-1))*(a-2.3722)-.1046792095*(a-2.3722)^2)

How can I do that?

Thank you

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