MaplePrimes Questions

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

I need to use convert of complex exponentials to trig, but only to convert exp(I*x) to cos/sin using Euler formula.

The problem is that, since this is done in code without looking at what is inside the exp(), Maple will also convert non complex exponentials as exp(x) to hyperpolic trig which I do not want.  An example will make this clear

For an example, given exp(3*I*x - x)  and applying convert/trig to this it gives 

             (cosh(x) - sinh(x))*(cos(3*x) + sin(3*x)*I)                       --(1)

But I only want to conver the exp(3*I*x) part of the of the above to obtain

          exp(-x) *  (cos(3*x) + sin(3*x)*I)                          ---(2)

I can break  exp(3*I*x - x) first using expand command and obtain  exp(-x) exp(3*I*x) and then parse this and filter out the complex exponentials (may be using select with has I) and then use convert on those terms only leaving the non-complex exponentials alone. But this gets messy for more complex exponentials.

Is there an easy way to tell Maple  to convert expression of the form exp(I*f(x) + g(x)) to trig but only to sin/cos, hence leaving the exp( g(x) ) as a factor? I looked at help but see nothing there so far.

Maple 2021.2

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

L=100 H, R=20 ohm, C=1/401 F, DC=200 V and Impulse =2000 V. q(0)=0 and Q'(0)=2000/L.
Maple new user can't show the ODE function. I just use the toolber menu. 

Tokoro.

restart;
with(inttrans):
U__0:=20:

U := t -> U__0*exp(-1/10*t)*cos(2*t):

plot(U(t), t = 0 .. 2*Pi,
     axis[2] = [tickmarks = [0 = 0, 20 = U__0]],
     labels = [t, 'U(t)'], size=[500,300]);

 

laplace(U(t), t, s)

200*(10*s+1)/((10*s+1)^2+400)

(1)

simplify(200*(10*s+1)/((10*s+1)^2+400))

(2000*s+200)/(100*s^2+20*s+401)

(2)

expand((2000*s+200)/(100*s^2+20*s+401))

2000*s/(100*s^2+20*s+401)+200/(100*s^2+20*s+401)

(3)

"Y(s):=((20)/(s)*100*s)/(100 s+20+401/(s))+(200/(s))/(100 s+20+401/(s))"

proc (s) options operator, arrow, function_assign; 2000/(100*s+20+401/s)+200/(s*(100*s+20+401/s)) end proc

(4)

" y(t):=invlaplace(Y(s),s,t):"

plot(y(t), t = 0 .. 2*Pi, axis[2] = [tickmarks = [0 = 0, 20 = U__0]], labels = [t, 'U(t)'], size = [500, 300])

 

Parse:-ConvertTo1D, "first argument to _Inert_ASSIGN must be assignable"

Error, illegal use of an object as a name

"L:=100:R:=20:C:=1/401:E:=200:L*i(0):=2000:q(0):=0:"

 

NULL

NULL

dsolve[interactive]()

 

Error, invalid function arguments

"diff(,t)"

 

plot([diff(q(t), t), 20*exp(-(1/10)*t)*cos(2*t)], t = 0 .. 2*Pi)

Warning, expecting only range variable t in expression diff(q(t),t) to be plotted but found name q

 

 

plot([q(t), (4000/401)*exp(-(1/10)*t)*sin(2*t)-(200/401)*exp(-(1/10)*t)*cos(2*t)+200/401], t = 0 .. 2*Pi)

Warning, expecting only range variable t in expression q(t) to be plotted but found name q

 

 

I am trying to perform a numerical integration of a matrix using parallel computing. I have found two packages to do that:

1. With Threads package

A:=Matrix([x,x^2],[2*x,sin(x)]);

Threads[Map](int,A,x=0..2,numeric=true);

This code does not parallelize at my Ryzen 5 processor and is using exactly 1 logical core during computation. The matrix is just an example, real matrices are much bigger.

kernelopts(multithreaded) returns true

kernelopts(numcpus) returns 6 when SMT is off and 12 when SMT is on (pretty weird though, it should always return 6)

2. With Grid package

A:=Matrix([x,x^2],[2*x,sin(x)]);

Threads[Map](int,A,x=0..2,numeric=true);

This leads to numerous messages:

"Error, attempting to assign to `int` which is protected.  Try declaring `local int`; see ?protect for details."

Meanwhile, the rezult seems OK and all cores are working to produce it.

What am I doing wrong?

Hello, 

I am doing symbolic calculations of multi-body kinematics which involves more than 40-degrees of freedom. I built a module that will construct initial kinematic calculations and it finshes fairly quicly, (about 20s). When I want to retrieve these calculations, stored as proprties of the module, it takes really a long time, we are talking more than 30min. It's strange because these calcualtions were already made during the initalization of the module, I am just retriving them for the purpose of writing the symbolic results to a file to later be used in Matlab as functions. 

Any word of advice?

Thanks. 

Hi guys,

I can not solve this integral with maple ! I really appreciate if someone can help me! Mathematical gives a solution in terms of hypergeometric function! 

p^2 , m, \epsilon, D > 0 and i is imaginary number 

Thanks 111.mw

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 was computing an integral (Running Maple 18 on Windows 10):

The classic lenght of arc Integral of sqrt(1+(dy/dx)^2) dx

In this case, the function was a cartesian circle (x-R)^2+y^2=R^2 isolated as y=sqrt(R^2-(x-R)^2)

When I do the integration, the result of the integral is not correct.
But if I change R for a, the result is correct. Why? This does not make any sense.

R wasn't assigned to any variable. The code was:

Good Integral

[>y:=expand(sqrt(a^2-(x-a)^2));
[>f:=expand(simplify(sqrt(1+diff(y,x)^2)));
[>S:=int(f,x)+K;

Wrong Integral

[>y:=expand(sqrt(R^2-(x-R)^2));
[>f:=expand(simplify(sqrt(1+diff(y,x)^2)));
[>S:=int(f,x)+K;

In fact, any UPPERCASE letter used as the radius gives me the wrong answer whereas any LOWERCASE letter gives me the proper result. Why is this?

Thanks and have a nice day
EDIT: I added a Screenshot

Dear all

I have a proc I would like to construct two vectors as output of  the proposed proc, the following code, contains  an example to illustrate this idea, 

output_pro.mw

thanks for any help 

Dear all

I have many points, and I would like to use pointplot to hold all plots in the same curve. 

plot_many_points.mw

thanks for any help 

dear all

I have a three lines of codes, used to create vectors, I would like to put these vectors in two columns and each columns has a title.

simple_code_table.mw

thank you

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.

First 340 341 342 343 344 345 346 Last Page 342 of 2428