Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

After saving and closing my maple file, it was corrupted when I tried to open it again later. 

I tried searching for a solution without any luck...can someone help me repair it?

Regnede_Eksamenssæt.mw

(When it asks to save it as Regnede_Eksamenssæt_1 only a small part of the document is included)

restart;
with(geometry):
with(plots):
_EnvHorizont:lName = 'x';
_EnvVerticalName = 'y';
Vdot := proc(U, V) local i; add(U[i]*V[i], i = 1 .. 2); end proc;
R := 5;
ang := [3/4*Pi, -(3*Pi)/4, -Pi/6,4*Pi/9];
seq(point(`||`(P, i), [R*cos(ang[i]), R*sin(ang[i])]), i = 1 .. 4);
pts:=[seq(P || i,i=1..4)]:
seq(dsegment(`||`(seg, i), [`||`(P, i), `||`(P, irem(i, 4) + 1)]), i = 1 .. 4);
Triangle(Tr1,[P1,P2,P4]);
EulerCircle(Elc1,Tr1,'centername'=o);
circle(cir, [point(OO, [0, 0]), R]);
dist := proc(M, N) sqrt(Vdot(M - N, M - N)); end proc;
display(draw([P1(color = black, symbol = solidcircle, symbolsize = 12), 
P2(color = black, symbol = solidcircle, symbolsize = 12), 
P3(color = black, symbol = solidcircle, symbolsize = 12), 
P4(color = black, symbol = solidcircle, symbolsize = 12),seg1,
seg2,seg3,seq4,Tr1,Elc1,
cir(color = blue)]), 
textplot([[seq( [ coordinates(`||`(P, i))[], convert(`||`(P, i), string)],i=1..4], 
,align = [above, right]), axes = none);
does not recognize neg4 or tr1? I don't know to manage. Thank you.

When we use Maple input to define a procedure in a worksheet in Document mode, how do we evaluate/execute the command. I am used to just hitting <Enter> when using 2d Math. Today, I've been trying to use Maple input, but when I hit <Enter> nothing happens, or something does happen that messes up the definition such that I get a 

Warning, premature end of input, use <Shift> + <Enter> to avoid this message.

right in the middle of the procedure which then generates a 

Error, global declaration unexpected outside procedure or module
Error, missing operator or `;`

and the only way to even execute and see these errors is by executing the whole worksheet. 

 

Attached is an example: 
 

f := proc(ix,iy)          global T:
        local x := trunc(ix), y := trunc(iy):
        print(x,y," Returning ",T[x][y]):
        return T[x][y]:
end:

g := proc (ix, iy) local x, y; global T; x := trunc(ix); y := trunc(iy); print(x, y, " Returning ", T[x][y]); return T[x][y] end proc

NULL


I can hit enter on the 2d math version, but not on the first 1d math version. On the 1d version, if I go to right after "end:" and hit <Enter> I get an error: Error, reserved word `end` unexpected.

Download 1dmathproc.mw

 

The documentation on plots:-densityplot says

Any additional arguments are interpreted as options which are specified as equations of the form option = value. For example, the option grid = [m, n] where m and n are positive integers specifies that the plot is to be constructed on an m by n grid at equally spaced points in the ranges a..b and c..d respectively. By default a 49 by 49 grid is used; thus 2401 points are generated, and 2401 colored cells are displayed.

Consider the following simple example

g := proc (x, y) print(x, y); return 55 end proc

plots:-densityplot(g, 1 .. 4, 2 .. 8, grid = [5, 5])

 

NULL

NULL


If we look at the output from the print statement inside of we see

Download DensityPlotGridQuestions.mw

That is, there are 16 points in the grid, not 5x5=25.

Is the documentation incorrect or did I miss something?

This question is about an aspect of the code below. In fact, the code could be made simpler to get at the question, but I chose to show you how the problem originated. 

We start with a 4x3 matrix A. There is a procedure, convertArrayToTable, that takes this matrix and creates a table. The table is such that the keys are the numbers in the first column of A. For each such key k1, the associated value is another table. The latter table has as keys the values in the second column that have k1 in the first column.

Now, further below, if you are curious I write about why I am doing this (what the exact real problem is). For now, I am generating a matrix B which in is formed by the concatenation of A and 2A, along the column (ie, A on top of 2A).

So for this matrix B, the table T that is generated has, for example a key 1 and the associated value is a table with keys 0.2 and 0.400000000000000.

I wish to be able to access T[1][0.400000000000000] but this is not working and I don't know why.
 

restart

  convertArrayToTable := proc(arr)
        local m, t, i, c1, c2, c3:

        m := ArrayTools:-Size(arr)[1]:
        t := Table([]):

        for i from 1 to m do:
                c1 := arr[i,1]:
                c2 := arr[i,2]:
                c3 := arr[i,3]:

                if not assigned(t[c1]) then:
                        t[c1] := table([ c2 = c3]):
                else:
                        t[c1][c2] := c3:
                end:
        end:
        print(t):

        return t:
end:NULL

A := Matrix([[1, .2, 3], [2, .2, 6], [3, .2, 9], [4, .2, 12]])

Matrix(%id = 36893488151958141876)

(1)

B := ArrayTools:-Concatenate(1, A, Matrix(`<|>`(A[1 .. (), 1], 2*A[1 .. (), 2 .. 3])))

Matrix(%id = 36893488151958124892)

(2)

T := convertArrayToTable(B)

t

(3)

T[1]

t[1]

(4)

T[1][.2]

3

(5)

print(T[1])

t[1]

(6)

assigned(T[1])

true

(7)

Why can't I access the following key?

assigned(T[1][.400000000000000])

false

(8)

assigned(T[1][.2])

true

(9)

NULL

Download tableDecimalIndex.mw

 

So now just a brief note on why I want to create such a table.

I want to create a density plot based on the values in the rows of B. In the case of the simple example shown above, the grid of values would be based on values of x from 1 to 4 and of y from 0.2 to 0.400000000000000. Then I would specify, say "grid=[5,3]" for an eight point grid. 

In this example I am assuming the points used by the densityplot procedure would be exactly the ones in the rows of B, ie (1,0.2), (2,0.2), (3,0.2), (4,0.2),(1,0.400000000000000),(2,0.400000000000000),(3,0.400000000000000),(4,0.400000000000000).

The function I would pass in the signature

densityplot(f, a..b, c..d)

would be a custom procedure that I am assuming would be called as f(x,y) and would simply look up T[x][y] in the table I created to get the value.

Of course in my real problem the grid has way more points.

I am making a lot of assumptions about this densityplot procedure, but the documentation isn't very clear at all.

Here is a proof of concept of what I am trying to achieve (note that below, I am avoiding the issue of the decimal keys in tables by using integers instead):
 

restart

  convertArrayToTable := proc(arr)
        local m, t, i, c1, c2, c3:

        m := ArrayTools:-Size(arr)[1]:
        t := Table([]):

        for i from 1 to m do:
                c1 := arr[i,1]:
                c2 := arr[i,2]:
                c3 := arr[i,3]:

                if not assigned(t[c1]) then:
                        t[c1] := table([ c2 = c3]):
                else:
                        t[c1][c2] := c3:
                end:
        end:
        print(t):

        return t:
end:NULL

A := Matrix([[1, 2, 3], [2, 2, 6], [3, 2, 9], [4, 2, 12]])

Matrix(%id = 36893488151876893500)

(1)

B := ArrayTools:-Concatenate(1, A, Matrix(`<|>`(A[1 .. (), 1], 2*A[1 .. (), 2], 2*A[1 .. (), 3])), Matrix(`<|>`(A[1 .. (), 1], 3*A[1 .. (), 2], 3*A[1 .. (), 3])), Matrix(`<|>`(A[1 .. (), 1], 4*A[1 .. (), 2], 4*A[1 .. (), 3])))

Matrix(%id = 36893488151876862548)

(2)

T := convertArrayToTable(B)

t

(3)

f := proc(x,y)
        global T:
        print(x,y," Returning ",T[x][y]):
        return T[x][y]:
end: 

g := proc (x, y) print(x, y); return 55 end proc

plots:-densityplot(g, 1 .. 4, 2 .. 8, grid = [5, 5])

 

plots:-densityplot(f, 1 .. 4, 2 .. 8, grid = [5, 5])

Error, (in Plot:-ColorScheme) unable to produce gradient shading from given data

 

NULL


In the above output, the output from the print statement in the f procedure is not being shown. Locally on my computer it is shown and is called at the expected values (the ones in the rows of B). So that is all good. The issue seems to always go back to keying in to tables with certain (but not all) decimal numbers

 

Download DensityPlot.mw

restart;
with(geometry):
with(plots):
_EnvHorizontalName = 'x':
_EnvVerticalName = 'y':
Vdot := proc(U, V) local i; add(U[i]*V[i], i = 1 .. 2); end proc:
R := 5:
ang := [2/3*Pi, -3*Pi*1/4, -Pi*1/6]:
seq(point(`||`(P, i), [R*cos(ang[i]), R*sin(ang[i])]), i = 1 .. 3):
seq(dsegment(`||`(seg, i), [`||`(P, i), `||`(P, irem(i, 3) + 1)]), i = 1 .. 3):
circle(cir, [point(OO, [0, 0]), R]):
dist := proc(M, N) sqrt(Vdot(M - N, M - N)); end proc:


display*([draw*[P1(color = black, symbol = solidcircle, symbolsize = 12), 
P2(color = black, symbol = solidcircle, symbolsize = 12), 
P3(color = black, symbol = solidcircle, symbolsize = 12), 
cir(color = blue)], 
textplot*([[coordinates(P1)[], "P1"], 
[coordinates(P2)[], "P2"], 
[coordinates(P3)[], "P3"]], align = [above, right])], axes = none);
                /[                
 plots:-display |[geometry:-draw [
                \[                

   P1(color = black, symbol = solidcircle, symbolsize = 12), 

   P2(color = black, symbol = solidcircle, symbolsize = 12), 

   P3(color = black, symbol = solidcircle, symbolsize = 12), 

                                       /[[-5  5  (1/2)      ]  
   cir(color = blue)], plots:-textplot |[[--, - 3     , "P1"], 
                                       \[[2   2             ]  

   [  5  (1/2)    5  (1/2)      ]  [5  (1/2)  -5      ]]  
   [- - 2     , - - 2     , "P2"], [- 3     , --, "P3"]], 
   [  2           2             ]  [2         2       ]]  

                         \]             \
   align = [above, right]|], axes = none|
                         /]             /


no figure drawn, Why? Thank you

Hi, I'm wondering why the first substituion works, but not the second. Can someone explain?

Let us begin with few simulations: 
 

restart;

CodeTools:-Usage(plots['pointplot3d'](Matrix((proc (_) options operator, arrow; [_[() .. (), 1]-_[() .. (), 3], _[() .. (), 2]-_[() .. (), 4], _[() .. (), 5]] end proc)(convert(ssystem("wolframscript -code \"RandomPoint[Simplex[IdentityMatrix[5]], 2*^4]\"")[-1], FromMma)), scan = [rectangular, columns], datatype = float[4]), scaling = constrained))

memory used=0.57TiB, alloc change=91.51MiB, cpu time=18.77m, real time=15.86m, gc time=4.91m

 

CodeTools:-Usage(plots['pointplot3d'](Matrix((proc (_) options operator, arrow; [_[() .. (), 1]-_[() .. (), 3], _[() .. (), 2]-_[() .. (), 4], _[() .. (), 5]] end proc)(convert(ssystem("wolframscript -code \"RandomPoint[Sphere[5], 2*^4, ConstantArray[List[0, 1], 5]]\"")[-1], FromMma)), scan = columns, datatype = float[4]), scaling = constrained))

memory used=0.56TiB, alloc change=-12.08MiB, cpu time=18.70m, real time=15.11m, gc time=5.69m

 

NULL


 

Download iDistributionVector.mws

Well, I'd like to prove (through the use of Maple): 

transform((x1, x2, x3, x4, x5) -> [x1 - x3, x2 - x4, x5])(inequal(And((x || (1 .. 5)) >=~ 0, norm([x || (1 .. 5)], 1) = 1))) # not Maple syntax

is equivalent to a filled pyramid

ImplicitRegion((X, Y, Z), 0 <= Z <= 1 - abs(X) - abs(Y)) # not SymPy syntax

transform((x1, x2, x3, x4, x5) -> [x1 - x3, x2 - x4, x5])(inequal(And((x || (1 .. 5)) >=~ 0, norm([x || (1 .. 5)], 2) = 1))) # not Maple syntax

is equivalent to a hemi-ball

ImplicitRegion((X, Y, Z), 0 <= Z <= sqrt(1 - X**2 - Y**2)) # not SymPy syntax

, and 

transform((x1, x2, x3, x4, x5) -> [x1 - x3, x2 - x4, x5])(inequal(And((x || (1 .. 5)) >=~ 0, norm([x || (1 .. 5)], 'infinity') = 1))) # not Maple syntax

is equivalent to a solid cuboid

ImplicitRegion((X, Y, Z), -1 <= X <= 1 & -1 <= Y <= 1 & 0 <= Z <= 1) # not SymPy syntax

. (Here, for the convenience of the descriptions, I utilize some non-standard notation from .) 
Note that ”two regions are equal" is a two-way property, which means the following proof 

is(Z >= 0) and is(Z <= 1 - abs(X) - abs(Y)) assuming (X, Y, Z) =~ (x1 - x3, x2 - x4, x5), x || (1 .. 5) >=~ 0, add(x || (1 .. 5)) = 1;
                              true
(*Accordingly, the latter region is a subset of the former one.*) 

is incomplete (because it's hard to determine whether the is routine always performs equivalent transformations in internal evaluation). 

So, can I execute such eliminations in Maple?

As the code:

poly := x^4 + 8*x + 12:
galois(poly, x)

"4T4", {"A(4)"}, "+", 12, {"(1 2 4)", "(2 3 4)"}

 Then I know it's Galois group has to be (isomorphic to) A4. And I can draw its Subgroup Lattice:

DrawSubgroupLattice(GaloisGroup(poly, x), 'indices')

But according to Galois's theory, each subgroup represents an intermediate field. As far as I know, ⑤⑥⑦⑧ are Q(r1),Q(r2),Q(r3) and Q(r4), respectively, where ri is the root of equation x^4+8x+12. But I have no idea what fields ②③④⑨ means. How do you calculate out those intermediate fields with maple?

I wanted to create an *m file with many @(x)  Matrix(x) , each of these matrices is 6-by-something , the matrices are not big in size, but they contain a LOT of sin/cos functions (of x vector). The only option I found is to use 

str := CodeGeneration:-Matlab(var,resultname = varname,output = string):

However, this takes endless time to execute despite the fact that the Maple operation to generate these matrices is, more or less, takes an acceptable time, but converting it to Matlab and output a string is an endless operation. 

I technically don't know why! These are matrices, they are not code or anything, just matercies. . 

I have a high end pc yet I couldn't get this line above to be executed in reasnable time (up to 30min!)

Dear researchers,

Greetings, I have unable to apply Nonlinear Least-Squares Methods  for an SIR parameter estimation. May you share me your Maple code model as a  sample parameter estimation ?

Thank you in advance!!!

Hi,

Below is the parametric identity, which i have found empirically: sqrt[pi] =(1/(2^j) ((k*gamma[5 + 2 j] gamma[ 1 + l] hypergeometricpfq[{1, 5/2 + j, 3 + j}, {3 + j + l/2, 7/2 + j + l/2}, -1])/ gamma[6 + 2 j + l] + ((k + m) gamma[7 + 2 j] gamma[ 1 + l] hypergeometricpfq[{1, 7/2 + j, 4 + j}, {4 + j + l/2, 9/2 + j + l/2}, -1])/gamma[8 + 2 j + l]))/(2^(-5 - 3 j - l) gamma[ 5 + 2 j] gamma[ 1 + l] (k hypergeometricpfqregularized[{1, 5/2 + j, 3 + j}, {3 + j + l/2, 7/2 + j + l/2}, -1] + 1/2 (3 + j) (5 + 2 j) (k + m) hypergeometricpfqregularized[{1, 7/2 + j, 4 + j}, {4 + j + l/2, 9/2 + j + l/2}, -1]

It seems to be true for arbitrary j,k,l,m parameters where j, k, l and m are signed integer

For all tried specific sets of {j,k,l,m} above identity was confirmed by both mathematica based wolframalpha and maple.

Could this identity be simplified?

How this identity could be proven either by using mathematica and/or analyticall

Thanks,

Best regards,

Alexander R. Povolotsky 

Is there any reason why the intersectplot can't plot the following curve?

plots:-intersectplot( x^2 + b*x + c , b^2 - 4*c , b = -4..4, c = -4..4, x = -4..4, color = red );

But it can plot the next one!

plots:-intersectplot( x , b^2 - 4*c , b = -4..4, c = -4..4, x = -4..4, color = red );

The output in the two cases respectively are shown below.

I am a bit confused that why the color option in the following plot3d does not work.

plot3d( [ b, ( b^2 ) / 4, -b / 2 ], b = -4 .. 4, c = -4 .. 4, thickness = 5, color = red  ); 

The output is the following.

I remember that once there was an option to provide to maple a given function and it produced a suitable DE that this function solves.

Can you remind me how to do it?

I remember there was such an option in the previous versions of maple.

Thanks in advance!

First 119 120 121 122 123 124 125 Last Page 121 of 2097