MaplePrimes Questions

If in a .mw file I have a Document Block with about 10 statements in it, what is a way to split it into two blocks that execute seperately? Currently, hitting enter all statements execute.

("Document Block" is the term that shows up when I hover to the left of the text of interest.)

(I know I can cut and paste the last five statements into a new document block, but it seem that there may be an easier way.)

Thanks and Cheers in advance . . .

There appears to be a bug in Maple 2023.0 (Build ID 1689885)  that does not allow you to access submenus when the window is maximized.  For example, trying to select "Insert --> Execution Group" does not work, nor does any other submenu (the submenu will not display and is not accessible).  The only workaround is to un-maximize the window, select the submenu (for example "Insert --> Execution Group --> Before Cursor"), and then re-maximize the window.  Everything works as it should as long as the window is not maximized.  This is on Microsoft Windows 11 with a 2160p monitor.  Any suggestions on how to fix this are appreciated.

I dont know if this is a well formulated question but if I had a set of PDES that have a constant appearing in them (say alpha), would there be a way to solve for the PDE such that the right had side is not zero but just has higher order order terms (say alpha^3 and higher).

For example consider (the random set of equations)
 

eq1 := alpha*diff(f(t, r), r,r) + diff(g(t, r), t) + alpha*g(t, r) = 0;
           

eq2 := alpha*diff(g(t, r), r) + diff(f(t, r), t,t) + f(t, r) = 0;

Is there a way to solve for the system of pde such that the right hand side is only terms of order alpha^3 and higher?
 

Example

diff(w(x), x, x) = F*((6*(-a^2/(2*L^2)+a^3/(3*L^3)))*x+2*a^2/L-a^3/L^2)/EI

diff(diff(w(x), x), x) = F*(6*(-(1/2)*a^2/L^2+(1/3)*a^3/L^3)*x+2*a^2/L-a^3/L^2)/EI

(1)

Eval(lhs(diff(diff(w(x), x), x) = F*(6*(-(1/2)*a^2/L^2+(1/3)*a^3/L^3)*x+2*a^2/L-a^3/L^2)/EI), x = L) = (`@`(simplify, eval))(rhs(diff(diff(w(x), x), x) = F*(6*(-(1/2)*a^2/L^2+(1/3)*a^3/L^3)*x+2*a^2/L-a^3/L^2)/EI), x = L)

Eval(diff(diff(w(x), x), x), x = L) = -F*a^2*(L-a)/(L^2*EI)

(2)

Can the expression above be further shortened by function composition and function application (to a single group of arguments)? I tried

(`@`(Eval, lhs) = `@`(`@`(simplify, eval), rhs))(diff(diff(w(x), x), x) = F*(6*(-(1/2)*a^2/L^2+(1/3)*a^3/L^3)*x+2*a^2/L-a^3/L^2)/EI, x = L)

Error, (in evalapply) invalid input: lhs expects 1 argument, but received 2

 

which does not work.
Since the error message is clear I am looking for a single argument command that could replace lhs and rhs.  

Analog to evalf, which accepts an index, I tried to replace lhs by

op[1](diff(diff(w(x), x), x) = F*(6*(-(1/2)*a^2/L^2+(1/3)*a^3/L^3)*x+2*a^2/L-a^3/L^2)/EI)

diff(diff(w(x), x), x), F*(6*(-(1/2)*a^2/L^2+(1/3)*a^3/L^3)*x+2*a^2/L-a^3/L^2)/EI

(3)

to do the same as

op(1, diff(diff(w(x), x), x) = F*(6*(-(1/2)*a^2/L^2+(1/3)*a^3/L^3)*x+2*a^2/L-a^3/L^2)/EI)

diff(diff(w(x), x), x)

(4)

Unfortuenatly this does not work. Are there any other options or have I reached an end point?

Would a single argument variant of op make sense for other purposes than the example above?


Download replacement_of_lhs_and_rhs_by_single_argument_function.mw

I have been using the RaiseLowerIndices to go from covectors to contravariant vectors.

RaiseLowerIndices(Contravariant_form_of _metric, One_Form, [1])

The above gives me the right answer.
But the following also gives me an answer which is different. I just dont know what it is calculating.

RaiseLowerIndices(Contravariant_form_of _metric, One_Form, [1,1]).

Could someone tell me what it is calculating?

将枫叶文档传输到手机后如何打印?

Dear all

Can I compute using maple intersection between discrete sets

intersection_sets.mw

thank you for your help 

I compute some properties of some graphs and try to store their edge sets and their corresponding properties. I stored them using matrices, but now I want to export them to a file (csv format).

with(GraphTheory):
graphs := [seq(RandomGraphs:-RandomGraph(8, 9), 1 .. 10)]:
M0:=Edges~(graphs):
M1:=Girth~(graphs):
M2:=Diameter~(graphs):
B := Matrix(1..3,[M0,M1,M2]);
Export("E:/B.csv", B):

 

he exported file's data is messy, and it is difficult for me to observe the corresponding properties of the graphs.  I hope they can be sorted into three columns as shown below.

PS: I know that if the data has only one column, it can be done as discussed earlier

Export("E:/M.csv", M):

To make the data appear clearer, it is best to keep suitable spacing between columns.

multi_dimensional_data.mw

When making a module with option object, help says 

To create a new class of objects, use the named module declaration syntax with option object.

and it gives an example.  But what is the difference from using the standard module syntax?

This seems to work the same but may be there are cases where it makes a difference?  Here is an example. second case below is what help says to use. But first case is the original module syntax. Both work the same in this simple example.

Can one use either syntax, or is there any subtle difference in semantics that will show under more complicated setup?

interface(version);

`Standard Worksheet Interface, Maple 2023.0, Windows 10, March 6 2023 Build ID 1689885`

restart;

1421372

person_class:=module()
  option object;
  export foo::static:=proc(_self,$)
    print("in foo");
    NULL;
  end proc;
end module;

o:=Object(person_class);
o:-foo();

_m2325067887584

_m2325067872032

"in foo"

restart;

1421372

module person_class()
  option object;
  export foo::static:=proc(_self,$)
    print("in foo");
    NULL;
  end proc;
end module;
o:=Object(person_class);
o:-foo();

module person_class () option object; end module

module person_class () option object; end module

"in foo"

 


Download syntax_of_OOP_module.mw

Hello,

is there a limit to the matrix size on which the Determinant(A) can operate? I am working on a project that generates a 22x22 matrix of coefficients of unknowns, which I built out of the GenerateMatrix() function.  If I use subs(omega=1, AA), the determinant is calculated. Still, I want the determinant in terms of omega so I can solve for Determinant(A)=0 in order to find the natural frequencies and then find my unknown coefficients.

When I use the Determinant function on my symbolic matrix is always returns 0. I know from using smaller matrices that it can do symbolic determinants. If there is a better way to do what I am trying to do, please let me know!

Thanks!

Is it possible to use the ~ when using Matrix multiplications, where the second part of the operand are list elements?

The first part of the matrix multiplication remains unchanged, while the second one should be each element of the list.

The result should be a list of vectors / matrices again.

with(Units:-Simple)

alpha := 20*Unit('arcdeg')

20*Units:-Unit(arcdeg)

(1)

TransMatrix := Matrix([[cos(alpha), sin(alpha)], [-sin(alpha), cos(alpha)]])

Matrix(%id = 36893490153509525972)

(2)

pt := Vector(2, {(1) = -25.0, (2) = 0.})

Vector[column](%id = 36893490153504789076)

(3)

ptlist := [Vector(2, {(1) = -25.0, (2) = 0.}), Vector(2, {(1) = 25.0, (2) = 0.})]

[Vector[column](%id = 36893490153504761724), Vector[column](%id = 36893490153504761844)]

(4)

pt_trans := evalf(TransMatrix.pt)

Vector[column](%id = 36893490153514236012)

(5)

pl_translist := evalf(TransMatrix.ptlist)

Matrix(%id = 36893490153509525972).[Vector[column](%id = 36893490153504761724), Vector[column](%id = 36893490153504761844)]

(6)

TransMatrix.ptlist

Error, number of dimensions must be the same for all container objects in an elementwise operation

 

NULL

Download MatrixMultiplicate.mw

In traditional OOP, one can have a base class with its own constructor. Then extends this class, where the sub class has also its own consturctor. The first thing one does in the extending class constructor is to initialize the base class by calling base class constructor directly, before finishing the initializing of the extending class.

This is done in different ways. in Java the call super(...) is used for example. in C++ it is done by explicit call to base class constructor. Here is an example.  from the net.

But in Maple, I am not able to duplicate this. Because once ModuleCopy is defined (which is the name for the module constructor) in the base class, I can't have another ModuleCopy in the extending/child class. Maple complains because the name already exists.

In the following example, the base class represents a generic ode.

Then the extending/child class is meant to represent a first order ode which extends the base class and adds some specific functions that only meant to apply for first order ode type.

Later on I want to make a second order ode class and so on. All extend the base ode class. 

My question is: How to extend a class in Maple and have the extending/child class constructor call the base class constructor if one can't have more than one constructor when extending?

This Maple help shows one example of inhertance using Objects but this example does not use a constructor in the base of the child. I am assuming one needs to use ModuleCopy as the name for the constuctor since it specifies how an object is copied by Object so can't make my own function and pretend it is the constructor.

restart;

interface(version)

`Standard Worksheet Interface, Maple 2023.0, Windows 10, March 6 2023 Build ID 1689885`

ode_class:=module()
   option object;
   local ode::`=`;
   local x::symbol;
   local y::symbol;

   #constructor
   export ModuleCopy::static := proc( _self::ode_class, proto::ode_class, ode, func, $ )
    _self:-ode:= ode;
    _self:-y:=op(0,func);
    _self:-x:=op(1,func);
   end proc;

   export get_ode::static:=proc(_self,$)
     return _self:-ode;
   end proc;

   export get_x::static:=proc(_self,$)
     return _self:-x;
   end proc;

   export get_y::static:=proc(_self,$)
     return _self:-y;
   end proc;


end module;

_m2586207352192

first_order_ode_class:=module()
   option object(ode_class);
   local is_linear_ode::truefalse;

   #constructor
   export ModuleCopy::static := proc( _self::first_order_ode_class, proto::first_order_ode_class, ode, func, $ )
    #How to call base class above constructor here?

    _self:-is_linear_ode:= false;
   end proc;

   export is_linear::static:=proc(_self,$)
          return _self:-is_linear_ode;
   end proc;
          
end module;

Error, (in first_order_ode_class) export `ModuleCopy` is declared more than once

ode:=Object(first_order_ode_class,diff(y(x),x)=sin(x),y(x));

_m2586207319808

ode:-get_ode();
ode:-is_linear()

false

 


Download base_class_constructor.mw

UPDATE

This is workaround which seems to work OK. do not use ModuleCopy to construct an object, but have custom named function for each base and each child and call these explicitly.

So child constructor will  now call its parent constuctor using the specific name of that function. May be using some convention as  module_name_constuctor(....)   passing it what the parents needs.

The drawback is that now copying an object does not work automatically since ModuleCopy is missing.  but so far, I never had the need to copy one object to another, so I can live without it for now.
 

1421372

restart;

1421372

ode_class:=module()
   option object;
   local ode::`=`;
   local x::symbol;
   local y::symbol;

   #constructor
   export ode_constructor::static := proc( _self,ode::`=`, func, $ )
     print("inside ode_class constrructor");
    _self:-ode:= ode;
    _self:-y:=op(0,func);
    _self:-x:=op(1,func);
    NULL;
   end proc;

   export get_ode::static:=proc(_self,$)
     return _self:-ode;
   end proc;

   export get_x::static:=proc(_self,$)
     return _self:-x;
   end proc;

   export get_y::static:=proc(_self,$)
     return _self:-y;
   end proc;

end module;

_m2325067887904

first_order_ode_class:=module()
   option object(ode_class);
   local is_linear_ode::truefalse;

   #constructor
   export first_order_ode_constructor::static := proc( _self,ode::`=`, func, $ )
      print("inside first_order_ode_class constrructor");
      #call base class constructor
      _self:-ode_constructor(ode,func);
      #finish rest of constructor  
     _self:-is_linear_ode:= false;
     NULL;
   end proc;

   export is_linear::static:=proc(_self,$)
          return _self:-is_linear_ode;
   end proc:
          
end module;

_m2325067872672

o:=Object(first_order_ode_class);
o:-first_order_ode_constructor(diff(y(x),x)=1,y(x));

_m2325067860896

"inside first_order_ode_class constrructor"

"inside ode_class constrructor"

o:-get_ode()

diff(y(x), x) = 1

o:-is_linear()

false

 


I think Maple OOP is not fully OOP,  but it is better than nothing.

Download base_class_no_constructor.mw

 

I have a function (Hamilton-Jacobi-Bellman, HJB)

H:=(y,u,t)->y^(2)(t)+u^(2)(t)+1/(2)(x(t))^(4) +(∂)/(∂ x)(V(t))*u(t)

When I try to do

diff(H(y, u,t), u(t))

I get an invalid derivative error. Even if I remove the partial derivative, I still get the error. Does anyone know of to fix this?

Thanks

Hello,
I wonder why in the collect function:  collect(exp, abs (x-x0)) work and collect(exp, x-x0) doesn't? 
I would like to use both, any tip how to change the x-x0 to be seen like abs (x-x0), Or maybe another solution better than the collect function

Merci 

Best regards 

Please how do I compute the div n,  (n.curl n), (n.curl n)^2 and (n x curl n) and  (n x curl n)^2 given the information below: 

restart; restart; with(VectorCalculus); with(LinearAlgebra);

I.e.,

n = (cos(theta(x,y), sin(theta(x,y), 0).

I tried 

divn := Divergence(proc (x, y, z) options operator, arrow; `<,>`(n) end proc);

but received: Error, (in VectorCalculus:-Divergence) the procedure must evaluate to a Vector

First 86 87 88 89 90 91 92 Last Page 88 of 2308