Maple 2021 Questions and Posts

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

restart

with(Physics)

Setup(spacetime)

[spacetimeindices = greek]

(1)

Physics:-Version()

`The "Physics Updates" version in the MapleCloud is 1142 and is the same as the version installed in this computer, created 2022, February 12, 11:16 hours Pacific Time.`

(2)

Define(t[mu])

{Physics:-Dgamma[mu], Physics:-Psigma[mu], Physics:-d_[mu], Physics:-g_[mu, nu], t[mu], Physics:-LeviCivita[alpha, beta, mu, nu]}

(3)

NULL

SumOverRepeatedIndices(t[mu]*t[`~mu`])

t[1]*t[`~1`]+t[2]*t[`~2`]+t[3]*t[`~3`]+t[4]*t[`~4`]

(4)

NULL

SumOverRepeatedIndices(t[mu]*t[`~mu`])

t[1]*t[`~1`]+t[2]*t[`~2`]+t[3]*t[`~3`]+t[4]*t[`~4`]

(5)

NULL

SumOverRepeatedIndices(t[mu]*t[`~μ`])

t[mu]*t[`~μ`]

(6)

NULL

Download greek-index.mw

How to find the axis and focus of a parabola whose equation we know ? Thank you.

Why int gives this error? Is this a known problem?

Update

fyi, This is reported to Maplesoft.

Here is updated worksheet. The int() command does not generate the error the second time it used, but generates the error the very first time used. Hopefully will be fixed in 2022 Maple.
 

interface(version);

`Standard Worksheet Interface, Maple 2021.2, Windows 10, November 23 2021 Build ID 1576349`

restart;

Example 1

 

expr:=(7*x - 3 + sqrt(x^2 + (x^3*(x - 1)^2)^(1/3) - x) + sqrt(-2*((-x^2 + x + (x^3*(x - 1)^2)^(1/3)/2)*sqrt(x^2 + (x^3*(x - 1)^2)^(1/3) - x) + x^2*(x - 1))/sqrt(x^2 + (x^3*(x - 1)^2)^(1/3) - x)))/(12*x*(x - 1));

(1/12)*(7*x-3+(x^2+(x^3*(x-1)^2)^(1/3)-x)^(1/2)+(-2*((-x^2+x+(1/2)*(x^3*(x-1)^2)^(1/3))*(x^2+(x^3*(x-1)^2)^(1/3)-x)^(1/2)+x^2*(x-1))/(x^2+(x^3*(x-1)^2)^(1/3)-x)^(1/2))^(1/2))/(x*(x-1))

int(expr,x)

Error, (in IntegrationTools:-Indefinite:-AlgebraicFunction) invalid argument for sign, lcoeff or tcoeff

int(expr,x)

int((1/12)*(7*x-3+(x^2+(x^3*(x-1)^2)^(1/3)-x)^(1/2)+(-2*((-x^2+x+(1/2)*(x^3*(x-1)^2)^(1/3))*(x^2+(x^3*(x-1)^2)^(1/3)-x)^(1/2)+x^2*(x-1))/(x^2+(x^3*(x-1)^2)^(1/3)-x)^(1/2))^(1/2))/(x*(x-1)), x)


 

Download int_problem_feb_13_2022.mw

This also looks like an applyrule bug.

restart;

kernelopts(version);

`Maple 2021.2, X86 64 LINUX, Nov 23 2021, Build ID 1576349`

double_angle_rule := [
        sin(x::name/2)*cos(x::name/2) = 1/2*sin(x),
        sin(x::name/2)^2 = 1/2*(1-cos(x)),
        cos(x::name/2)^2 = 1/2*(1+cos(x))
];

[sin((1/2)*x::name)*cos((1/2)*x::name) = (1/2)*sin(x), sin((1/2)*x::name)^2 = 1/2-(1/2)*cos(x), cos((1/2)*x::name)^2 = 1/2+(1/2)*cos(x)]

C := < cos(1/2*u)*sin(1/2*u), cos(1/2*u)^2 >;

Vector(2, {(1) = cos((1/2)*u)*sin((1/2)*u), (2) = cos((1/2)*u)^2})

This application fails. Why?

applyrule~(double_angle_rule, C);

Error, dimension bounds must be the same for all container objects in an elementwise operation

Download applyrule-bug2.mw

 

This looks like a bug to me but please correct me if it is not.

restart;

kernelopts(version);

`Maple 2021.2, X86 64 LINUX, Nov 23 2021, Build ID 1576349`

half_angle_rule := [
        sin(x::name) = 2*sin(x/2)*cos(x/2),
        cos(x::name) = 1 - 2*sin(x/2)^2
];

[sin(x::name) = 2*sin((1/2)*x)*cos((1/2)*x), cos(x::name) = 1-2*sin((1/2)*x)^2]

In this example, Maple applies the rule to the first element only.
It should apply to both.

A := < sin(u), sin(u) >;
applyrule~(half_angle_rule, A);

Vector(2, {(1) = sin(u), (2) = sin(u)})

Vector[column](%id = 36893628627946684772)

In this example, Maple applies the rule to the second element only.
It should apply to both.

B := < cos(u), cos(u) >;
applyrule~(half_angle_rule, B);

Vector(2, {(1) = cos(u), (2) = cos(u)})

Vector[column](%id = 36893628627946688132)

Download applyrule-bug1.mw

 

How to trace the 2 parabolas that pass through 4 cocyclical points. Thank you

Hello all. I'm using version 2021.2 to try to make some simple energy plots for my research. The math is pretty straightforward, but for some reason I cannot get the results to plot properly. My code is below:

restart;
A := 7.17;
B := 2.56*10^(-3);
C := 0.08*10^5;
_local(D);
1;
D := 0*10^(-6);
                           A := 7.17

                      B := 0.002560000000

                          C := 8000.00

                             D := 0

T_0 := 298; 

G0 := -71.398;

S0 := 45.106;

Hf := -57.95;

 

cp := A + B*T + C/T^2 + D(T)^2;             

                           

`&Delta;H` := int(cp, T = T_0 .. T);

`&Delta;S` := int(cp/T, T = T_0 .. T);
           
G := -S0*T - T*`&Delta;S` + Hf + `&Delta;H`;

plot(G, T = T_0 .. T_max);

Which yields the following error message:

"Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct"

I've looked through everything I can find on this issue, and I'm coming up empty. Anyone know what's happening here?

Dear colleagues.

I use gradplot for a displacement vector in x-direction only, as foolows

gradplot(u1(x), x = 0 .. a, y = 0 .. b, grid = [10, 10], arrows = SLIM, color = u1(x), T, caption = typeset("The displacement field"), fieldstrength = fixed, size = [0.3, 0.5])

I need to make color legend to show the minimum and maximum value and in between for the displacement.

Amr

We have just issued a critical fix to Maple, MapleSim, and Maple Flow running on macOS.

We have heard from some users who were experiencing serious problems with doubled characters while using Maplesoft products on macOS, including these reports on MaplePrimes. Further investigation determined that these problems appear specifically on macOS 11 and macOS 12.  I am happy to report that we have now corrected the problem, and a patch is available. 

Anyone who uses macOS 11 or macOS 12 should install this update immediately. We also strongly recommend that all macOS users install this update, to avoid problems that may be triggered by future updates to your operating system.

To obtain this update:

For those who have experienced problems, we apologize for the inconvenience and thank you for your patience while we worked to find a solution.

I try to know an equation of the tangent on the point [0.504244923, 0.3781836925] on the hyperbola7*x^2 - 7*y^2 - 12.0*x + 9.0*y + 2.25 - 2*x*y=0.How can I do that? Thank you.

I see that one of the parameters of the  function Graph accepts a Array of neighbors.

So I gave it a try. 

G := GraphTheory:-Graph([1,2],[[2],[1]])

G := `Graph 10: an undirected unweighted graph with 2 vertices and 1 edge(s)`

It looks pretty good. But there's something wrong with the following codes.

G := GraphTheory:-Graph([0,1],[[1],[0]])

Error, (in GraphTheory:-Graph) invalid vertex 0 in list of neighbors

G := GraphTheory:-Graph(["0","1"],[["1"],["0"]])

Error, (in GraphTheory:-Graph) cannot determine if this expression is true or false: 1" < 1 or 2 < "1
 

G := GraphTheory:-Graph(["a","b"],[["b"],["a"]])

Error, (in GraphTheory:-Graph) cannot determine if this expression is true or false: b" < 1 or 2 < "b
 

How to use  Array of neighbors in  Graph  correctly?

 

PS: The source of the problem is that I got the following list of adjacencies of a graph  in Python and I want to convert it to  a graph in Maple. Its vertices are [0,1,2, ..., 9].

[[1, 2, 3, 4, 5, 6], [0, 2, 3, 4, 7, 8],
 [0, 1, 3, 5, 7, 9], [0, 1, 2, 6, 8, 9],
 [0, 1, 5, 6, 7, 8], [0, 2, 4, 6, 7, 9], 
[0, 3, 4, 5, 8, 9], [1, 2, 4, 5, 8, 9], 
[1, 3, 4, 6, 7, 9], [2, 3, 5, 6, 7, 8]]

 

G := GraphTheory:-Graph([$0..9],[[1, 2, 3, 4, 5, 6], 
[0, 2, 3, 4, 7, 8], [0, 1, 3, 5, 7, 9],
 [0, 1, 2, 6, 8, 9], [0, 1, 5, 6, 7, 8],
 [0, 2, 4, 6, 7, 9], [0, 3, 4, 5, 8, 9],
 [1, 2, 4, 5, 8, 9], [1, 3, 4, 6, 7, 9], 
[2, 3, 5, 6, 7, 8]])

Error, (in GraphTheory:-Graph) invalid vertex 0 in list of neighbors

I've got a really bizarre error. In my quite short code, if I do not have the print statement, I get the error message 'Error, (in fib_even_sum) illegal use of an object as a name'. If I do use the print statement, the code runs fine, albeit having printed an unnecessary zero.

Here's the code:

fib_even_sum := proc()::integer:

options threadsafe,autocompile:

uses combinat:

local val := 0, n := 1, FN := 0:

#print(%);

while FN <= 4000000 do:

if type(FN,even) then:

val += FN:

else end if:

++n:

FN := fibonacci(n):

end do:

return val:

end proc:

fib_even_sum();

I can't see what would be making it behave like this; perhaps I'm missing something really obvious?

Hello, everyone! The following results about r has many. I want to put the results together(assume they are equal to  zero) and solve them. So my questions are how to put the results together and solve them? Thank you very much! And have a good day!

restart; w:=1/(4*(exp(1/2)+exp(-1/2))+2*(exp(1/2)+exp(-1/2))^2): g1:=x->sum(a[i]*x^i,i=0..50): for j from 0 to 50 do r:=(1/2+w)*(g1(j+1)+g1(j))-w*(g1(j-1)+g1(j+2))-g1(2*j+1): end do

I am trying to calculate the number of  complete subgraphs K4 of a graph. Based on some similar discussions, like following links,

I wrote the following codes:

NumberOfK4:=proc(g::Graph)
local  n,N, i, j, k,l, g1,G1;
uses GraphTheory;
n:=NumberOfVertices(g);
g1 := RelabelVertices(g, [$ i = 1..n]):
N:=0:
 for i from 1 to n-3 do
    for j from i+1 to n-2 do
         for k from j+1 to n-1 do
             for l from k+1 to n do
                G1:=InducedSubgraph(g1,[i,j,k,l]);
                   if NumberOfEdges(G1)=6 then N:=N+1; fi;
               od;
            od; 
         od;
  od;
N;
end proc:
with(GraphTheory): with(SpecialGraphs):
g:=CompleteGraph(5);
g1:=LineGraph(g);
NumberOfK4(g1)

5

I know the above codes are supposed to be inefficient in terms of speed. We want to improve this codes. One way I know  that is to take advantage of  the efficient graph theory programs such as igraph

Recently I learned how Maple calls external C programs. 

The define_external command links in an externally defined function (for example, from a DLL under Windows, or from a shared library under UNIX), and produces a Maple procedure that acts as an interface to this external function.

From the help documentation, we need to compile the DLL files from the  source of C language. If it is a C program that does not need additional libraries, we can compile successfully, such as help documents

    void mat_mult( double *A, double *B, double *C, int I, int J, int K )
    {
      int i, j, k;
      double t;
      for( i = 0; i < I; ++i )
        for( k = 0; k < K; ++k ) {
          t = 0.0;
          for( j = 0; j < J; ++j )
            t += A[i*J+j] * B[j*K+k];
          C[i*K+k] = t;
    }
    }

No offense, maple has relatively few functions on graph theory so far, while Sage has a strong advantage because of its ability to integrate open network resources. I think sage is considered better for graph theory researchers because of this.

I don't know if Maple has any guidance on integrating a publicly available  graph theory library ,such as igraph . 

Where is the difficulty of using the written source code? And my computer system is Windows 10 , are there any special requirements. If Maple does this better, it might be a wonderful thing for graph theorists.

On my PC I can't see the plus and minus sign in the quotient expression when using Student:-Basics:-LongDivision.

Is this a know display issue and is there to correct it?

Windows 10, Maple 2021.2

interface(version);

`Standard Worksheet Interface, Maple 2021.2, Windows 10, November 23 2021 Build ID 1576349`

restart;

A:=4*x^4;
B:=3*x^2-60*x+36;
Student:-Basics:-LongDivision(A,B,x); #NOTICE, no + sign shows in quotient

A := 4*x^4

B := 3*x^2-60*x+36

"[[(`%+`(3 x^2,-60 x,36)),[[,(4 x^2)/3,(80 x)/3,1552/3,],[),4 x^4,,,,],[,(4 x^4-80 x^3+48 x^2)/(),],[,,80 x^3-48 x^2,,],[,,(80 x^3-1600 x^2+960 x)/(),,],[,,,1552 x^2-960 x,,,],[,,,(1552 x^2-31040 x+18624)/(),,,],[,,,,30080 x-18624,,,,]]]]"

rem(A,B,x);
quo(A,B,x); #signs shows up here OK

30080*x-18624

(4/3)*x^2+(80/3)*x+1552/3

 

Download no_signs.mw

First 13 14 15 16 17 18 19 Last Page 15 of 35