Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

In this example, i have a top module A. Inside it, I have module named my_RECORD (which happened to be option object) that I want to return back to caller when they call a proc.

Maple allows me to declare the proc to return my_RECORD. No problem., But when making a local variable inside the proc and using o::my_RECORD it complains  that my_RECORD does not exist. 

The solution is to change o::my_RECORD to o::A:-my_RECORD

My question why it did not complain the same way on the return value on the proc?   for me, they are both semantically the same. One says the proc returns this type, and the other says the local variable is this type. So why had to do A:-my_RECORD on one but not the other? 

Here is an example. Maple 2021.2 on windows 10.

restart;

interface(warnlevel=4);
kernelopts('assertlevel'=2):

3

A:=module()
 #this is the RECORD to return
  local module my_RECORD()
   option object;
   export data::string:="";
  end module;
   
  export do_analysis:=proc()::my_RECORD;   
    local o::my_RECORD; #error here. But this is the same above line above?    
    o:=Object(my_RECORD);
    o:-data:="test";
    return o;        
  end proc;
end module;

_m2642451182336

A:-do_analysis()

Error, (in do_analysis) type `my_RECORD` does not exist

#FIXED BELOW
restart;

A:=module()
    #this is the RECORD to return
    local module my_RECORD()
        option object;
        export data::string:="";
    end module;
   
    export do_analysis:=proc()::my_RECORD;
          local o::A:-my_RECORD;    
          o:=Object(my_RECORD);
          o:-data:="test";
          return o;        
    end proc;
end module;

_m2642339719872

A:-do_analysis()

module my_RECORD () export data::string; option object; end module

 

Download A_no_lib.mw

I often create diagrams in Maple and export them so I can embed them in a Word Doc.  Lately, when I right-click on the picture so I can select "export," the entire program closes.   It seems to happen more when the picture is in 3D.   Am I doing something wrong?     Thanks.

           David

Hi, I am trying to enter into the Mini-Course Computer Algebra for Physicists from the help, but instead of going to the page I get the help page of Physics[FeynmanIntegral]. Can anyone confirm that this happens to them on Maple 2021.2?

Kevin

But ODEsteps supports simliar ODEs (see attached).
Is the ODESteps command not generic enough to cover the pendulum or have I missed something?

ODESteps.mw

Other than saving few bytes of memory, why would one use ::static for methods of Object?

I found that if I use ::static, then I have to add prefix _self:- each time an object data member is referenced anywhere, making the code very hard to read.

Imagine having to write  _self:-x + 3* _self:-x^2 + 2* _self:-y^3 and so on all the time, instead of just x+3*x^2+2*y^3. (where it is assumed here that x,y happened to be object private data members and not local variables for a proc inside the module).

But then I found if I remove  ::static now _self:- no longer needed and can still get the benefit of using the object and the code works as before, but the code is now much more readable. 

I know that by not using static, then a copy of each method is made for each new object.

I am OK with that. As I do not use that many objects any way (few at a time before GC cleans the ones I used).

But the benefit of much more readable code far outweights the little extra memory needed, and memory is cheap these days anyway. I got lots of RAM. An extra few MB's is not a big deal.

What Am I missing here? Why does all the Maple help and documenation say that one should use static for object methods then? But do not mention that by not using static:: then the code will become more readable since _self:- is not needed to be appeneded to each variable or method name.

Here is an example below to compare. 

First example uses ::static methods, and the second does not.

One can see the difference The code is more clear in the second.   Is there something else I am overlooking by not using ::static . I am still learning OOP in Maple, and could be overlooking something else. I definitly do not want to code using _self:-variable_name all the time if I have to use OOP in Maple as it makes the code hard to read. 

Notice that in both examples, and for the exported methods, I used _self as first argument. This is OK. This is meant to allow client of the object to call it using object:-method() syntax which is what I prefer instead of method(object,....). syntax.

I am talking about the execssive use of _self internal to the module/object code when having to use ::static. methods.

restart;

person_class_STATIC:=module()
   option object;
   local age:=5;   

   export set_age::static:=proc(_self,age,$)      
     _self:-age:=age:
   end proc:      

   export update_age::static:=proc(_self,age,$)      
      do_the_update(_self)
   end proc:      

   local do_the_update::static:=proc(_self,$)
      _self:-age:=_self:-age+1;
      _self:-age:=sqrt(_self:-age^2+3);
   end proc;

   export get_age::static:=proc(_self,$)      
     return _self:-age;
   end proc:      

end module:

o:=Object(person_class_STATIC);
o:-set_age(100);
o:-get_age();
o:-update_age();

o2:=Object(person_class_STATIC);
o2:-get_age();

_m1982588380672

100

100

2*2551^(1/2)

_m1982698669216

5

person_class_NO_STATIC:=module()
   option object;
   local age:=5;   

   export set_age:=proc(_self,_age,$)      
     age:=_age:
   end proc:      

   export update_age:=proc(_self,$)      
      do_the_update()
   end proc:      

   local do_the_update:=proc()
      age:=age+1;
      age:=sqrt(age^2+3);
   end proc;

   export get_age:=proc(_self,$)      
     return age;
   end proc:      

end module:

o:=Object(person_class_NO_STATIC);
o:-set_age(100);
o:-get_age();
o:-update_age();

o2:=Object(person_class_NO_STATIC);
o2:-get_age();

_m1982698652256

100

100

2*2551^(1/2)

_m1982698629312

5

 

Download OOP.mw

Hi, I'm trying to solve auxilary equation to find its familes but I don't know what I'm doing wrong as I'm using following code:

famtemp := (diff(z(xi), xi))^2-a*z(xi)^2-b*z(xi)^3-c*z(xi)^4;

fam1 := simplify(`assuming`([dsolve(famtemp)], [b::real, a::real, c::real, -4*a*c+b^2 > 0, a > 0]))

I want to get the following family:

fam1 := 2*a*sech(sqrt(a)*xi)/(sqrt(-4*a*c+b^2)-b*sech(sqrt(a)*xi));

I hope someone will help me to solve it.

Thanks

HOW TO DECIDE THE TRIPLE INTEGRAL IS POSITIVE, NEGATIVE OR ZERO WITHOUT CALCULATING IT?

Hey guys,

How can I create a bar chart or a column chart, with specific x values under the bars.

Would be great If someone could help me.

Thank you;) 

Is there some basis containing polynomials of the form x[1]^p*x[2]^q+x[2]^p*x[3]^q+x[3]^p*x[1]^q, (p,q posint)?
Are there known relationships between these?

Note: these are not the symmetric polynomials.

I want to arrange this equation in term of powers of x and then plot the  real and imagenery part of x vs y. How can I do this with Maple?
1-alpha*((1/x^2)+(1/(x-y)^2)+(1/(x+ay)^2))=0;

1.mw     (alpha and a are constant, for example alpha=1 and a=0.3)

Does anyone by any chance know why I might be getting this error?

I'm working with polynomials that have coefficients with many digits (16).

Thank you in advance,

Hi,

I want to solve system of  PDE equations by maple and i dont know how can i write it codes that can solve them for me. Can anyone help me please??!!

 

So I just noticed that if you want to animate something in real time, the best you can achieve is something close but not exact.

For example lets say we have a ball travelling 22 m/s over 1000 m and I want to animate that in real time. 

ball := proc(x, y) plots[pointplot]([[x, y]], color = blue, symbol = solidcircle, symbolsize = 40); end proc:
animate(ball, [22*t, 0], t = 0 .. 1000/22, frames = floor(1000/22));

frames has to be an integer value so determining how long it will take and adjusting the frames to 1 frame per second.  It requires a bit of manipulation to get it right.  Is there a better way?  I suppose boosting the frame rate and increasing the number of frames would work but then it becomes cumbersome and any large period of times would use a high number of frames and consume enormous amounts of memory. 

Every time I open Maple it has the invitation to Login in the top right-hand corner.  I would like to sign in but have had quite a bit of trouble doing that.  I have a user name and password with Maplesoft web store and the same for MaplePrimes.  Should either of these work to log in? 

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